[NetworkPreferenceApp] WiFi SSID capability change
Adding an ability to assign certain PANS capabilities to selected SSIDs.
Bug: 180368798
Test: mma
Change-Id: I2fe3a77122e7ba74668b52149d1c5cce05f0c4b1
diff --git a/tests/NetworkPreferenceApp/res/layout/manager.xml b/tests/NetworkPreferenceApp/res/layout/manager.xml
index c2b94a3..9b545ee 100644
--- a/tests/NetworkPreferenceApp/res/layout/manager.xml
+++ b/tests/NetworkPreferenceApp/res/layout/manager.xml
@@ -17,11 +17,10 @@
style="@style/SectionContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:weightSum="7"
+ android:weightSum="3"
android:orientation="vertical">
<include layout="@layout/metric_display" />
<LinearLayout
- style="@style/SectionContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
@@ -29,7 +28,7 @@
<LinearLayout
style="@style/SectionContainer"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:layout_weight="1"
android:weightSum="2">
<TextView
@@ -52,106 +51,167 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_apply_latest_policy_on_boot"/>
- <ToggleButton
- android:id="@+id/reapplyPANSOnBootToggleButton"
+ <Switch
+ android:id="@+id/reapplyPANSOnBootSwitch"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textOff="@string/off"
- android:textOn="@string/on"
- android:checked="false"/>
+ android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
- style="@style/SectionContainer"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:weightSum="2"
- android:orientation="vertical">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/oem_paid_apps_text"
- android:labelFor="@+id/OEMPaidAppsEditText"/>
- <EditText
- android:id="@+id/OEMPaidAppsEditText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inputType="textNoSuggestions"/>
- </LinearLayout>
- <LinearLayout
- style="@style/SectionContainer"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:weightSum="2"
- android:orientation="vertical">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/oem_paid_no_fallback_apps_text"
- android:labelFor="@+id/OEMPaidNoFallbackAppsEditText"/>
- <EditText
- android:id="@+id/OEMPaidNoFallbackAppsEditText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inputType="textNoSuggestions"/>
- </LinearLayout>
- <LinearLayout
- style="@style/SectionContainer"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:weightSum="2"
- android:layout_weight="1"
- android:orientation="vertical">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/oem_paid_only_apps_text"
- android:labelFor="@+id/OEMPaidOnlyAppsEditText"/>
- <EditText
- android:id="@+id/OEMPaidOnlyAppsEditText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inputType="textNoSuggestions"/>
- </LinearLayout>
- <LinearLayout
- style="@style/SectionContainer"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:weightSum="2"
- android:orientation="vertical">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/oem_private_only_apps_text"
- android:labelFor="@+id/OEMPrivateOnlyAppsEditText"/>
- <EditText
- android:id="@+id/OEMPrivateOnlyAppsEditText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inputType="textNoSuggestions"/>
- </LinearLayout>
- <LinearLayout
- style="@style/SectionContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:weightSum="2">
- <Button
- style="@style/Button"
- android:id="@+id/applyConfigurationBtn"
+ <LinearLayout
+ style="@style/SectionContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="@string/button_apply_configuration"/>
- <Button
- style="@style/Button"
- android:id="@+id/resetNetworkPreferencesBtn"
+ android:weightSum="5"
+ android:orientation="vertical">
+ <LinearLayout
+ style="@style/SectionContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:weightSum="2"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/oem_paid_apps_text"
+ android:labelFor="@+id/OEMPaidAppsEditText"/>
+ <EditText
+ android:id="@+id/OEMPaidAppsEditText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textNoSuggestions"/>
+ </LinearLayout>
+ <LinearLayout
+ style="@style/SectionContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:weightSum="2"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/oem_paid_no_fallback_apps_text"
+ android:labelFor="@+id/OEMPaidNoFallbackAppsEditText"/>
+ <EditText
+ android:id="@+id/OEMPaidNoFallbackAppsEditText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textNoSuggestions"/>
+ </LinearLayout>
+ <LinearLayout
+ style="@style/SectionContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:weightSum="2"
+ android:layout_weight="1"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/oem_paid_only_apps_text"
+ android:labelFor="@+id/OEMPaidOnlyAppsEditText"/>
+ <EditText
+ android:id="@+id/OEMPaidOnlyAppsEditText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textNoSuggestions"/>
+ </LinearLayout>
+ <LinearLayout
+ style="@style/SectionContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:weightSum="2"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/oem_private_only_apps_text"
+ android:labelFor="@+id/OEMPrivateOnlyAppsEditText"/>
+ <EditText
+ android:id="@+id/OEMPrivateOnlyAppsEditText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textNoSuggestions"/>
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:weightSum="2">
+ <Button
+ style="@style/Button"
+ android:id="@+id/applyConfigurationBtn"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/button_apply_configuration"/>
+ <Button
+ style="@style/Button"
+ android:id="@+id/resetNetworkPreferencesBtn"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/button_reset_network_preference"/>
+ </LinearLayout>
+ </LinearLayout>
+ <LinearLayout
+ style="@style/SectionContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="@string/button_reset_network_preference"/>
+ android:weightSum="5"
+ android:orientation="vertical">
+ <LinearLayout
+ style="@style/SectionContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:weightSum="2"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/oem_paid_wifi_ssids_text"
+ android:labelFor="@+id/OEMPaidWifiSSIDsEditText"/>
+ <EditText
+ android:id="@+id/OEMPaidWifiSSIDsEditText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textNoSuggestions"/>
+ </LinearLayout>
+ <LinearLayout
+ style="@style/SectionContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:weightSum="2"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/oem_private_wifi_ssids_text"
+ android:labelFor="@+id/OEMPrivateWifiSSIDsEditText"/>
+ <EditText
+ android:id="@+id/OEMPrivateWifiSSIDsEditText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textNoSuggestions"/>
+ </LinearLayout>
+ <Button
+ style="@style/Button"
+ android:id="@+id/applyWifiCapabilitiesButton"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/button_apply_wifi_configuration"/>
+ </LinearLayout>
</LinearLayout>
</LinearLayout>
diff --git a/tests/NetworkPreferenceApp/res/layout/metric_display.xml b/tests/NetworkPreferenceApp/res/layout/metric_display.xml
index 8ec6342..230f729 100644
--- a/tests/NetworkPreferenceApp/res/layout/metric_display.xml
+++ b/tests/NetworkPreferenceApp/res/layout/metric_display.xml
@@ -8,8 +8,7 @@
style="@style/SectionContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:orientation="horizontal">
+ android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -35,8 +34,7 @@
style="@style/SectionContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:orientation="horizontal">
+ android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -62,8 +60,7 @@
style="@style/SectionContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:orientation="horizontal">
+ android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/tests/NetworkPreferenceApp/res/values/strings.xml b/tests/NetworkPreferenceApp/res/values/strings.xml
index d467660..38deeae 100644
--- a/tests/NetworkPreferenceApp/res/values/strings.xml
+++ b/tests/NetworkPreferenceApp/res/values/strings.xml
@@ -20,10 +20,10 @@
<string name="quit_app" translatable="false">Quit App</string>
<!-- Network Preferences Manager Fragment elements -->
- <string name="oem_paid_apps_text" translatable="false">OEM_PAID packages</string>
- <string name="oem_paid_no_fallback_apps_text" translatable="false">OEM_PAID_NO_FALLBACK packages</string>
- <string name="oem_paid_only_apps_text" translatable="false">OEM_PAID_ONLY packages</string>
- <string name="oem_private_only_apps_text" translatable="false">OEM_PRIVATE_ONLY packages</string>
+ <string name="oem_paid_apps_text" translatable="false">OEM_PAID packages (comma separated)</string>
+ <string name="oem_paid_no_fallback_apps_text" translatable="false">OEM_PAID_NO_FALLBACK packages (comma separated)</string>
+ <string name="oem_paid_only_apps_text" translatable="false">OEM_PAID_ONLY packages (comma separated)</string>
+ <string name="oem_private_only_apps_text" translatable="false">OEM_PRIVATE_ONLY packages (comma separated)</string>
<string name="button_apply_configuration" translatable="false">Apply Configuration</string>
<string name="button_reset_network_preference" translatable="false">Reset Network Preference</string>
<string name="label_is_pans_overridden" translatable="false">Is PANS overridden?</string>
@@ -34,6 +34,10 @@
<string name="label_metric_oem_private" translatable="false">OEM Private</string>
<string name="label_metric_total_oem_managed" translatable="false">Total OEM Managed</string>
+ <!-- Wifi PANS SSID control labels -->
+ <string name="oem_paid_wifi_ssids_text" translatable="false">Wifi SSIDs with OEM_PAID capability (comma separated)</string>
+ <string name="oem_private_wifi_ssids_text" translatable="false">Wifi SSIDs with OEM_PRIVATE capability (comma separated)</string>
+ <string name="button_apply_wifi_configuration" translatable="false">Apply WiFi changes</string>
<string name="no" translatable="false">No</string>
<string name="on" translatable="false">On</string>
diff --git a/tests/NetworkPreferenceApp/src/com/google/android/car/networking/preferenceupdater/components/MetricDisplay.java b/tests/NetworkPreferenceApp/src/com/google/android/car/networking/preferenceupdater/components/MetricDisplay.java
index 5e9b408..e4422aa 100644
--- a/tests/NetworkPreferenceApp/src/com/google/android/car/networking/preferenceupdater/components/MetricDisplay.java
+++ b/tests/NetworkPreferenceApp/src/com/google/android/car/networking/preferenceupdater/components/MetricDisplay.java
@@ -195,7 +195,6 @@
@WorkerThread
private void updateStats() {
- Log.d("METRIC_DISPLAY", "Timer tick... checking OEM traffic");
sendMessage(NetworkIdentity.OEM_PAID, combinedTrafficFor(NetworkIdentity.OEM_PAID));
sendMessage(NetworkIdentity.OEM_PRIVATE, combinedTrafficFor(NetworkIdentity.OEM_PRIVATE));
sendMessage(
diff --git a/tests/NetworkPreferenceApp/src/com/google/android/car/networking/preferenceupdater/components/PersonalStorage.java b/tests/NetworkPreferenceApp/src/com/google/android/car/networking/preferenceupdater/components/PersonalStorage.java
index 4fa1e6d..c884292 100644
--- a/tests/NetworkPreferenceApp/src/com/google/android/car/networking/preferenceupdater/components/PersonalStorage.java
+++ b/tests/NetworkPreferenceApp/src/com/google/android/car/networking/preferenceupdater/components/PersonalStorage.java
@@ -27,6 +27,7 @@
import android.content.SharedPreferences;
import android.util.SparseArray;
+import java.util.HashSet;
import java.util.Set;
/** This class will abstragate storage where OEM network policies are persisted */
@@ -35,6 +36,8 @@
private static final String KEY_REAPPLY_PANS_ON_BOOT_COMPLETE =
"key_reapply_pans_on_boot_complete";
+ private static final String KEY_OEM_PAID_WIFI_SSIDS = "key_oem_paid_wifi_ssids";
+ private static final String KEY_OEM_PRIVATE_WIFI_SSIDS = "key_oem_private_wifi_ssids";
private final SharedPreferences mSharedPrefs;
private final Context mContext;
@@ -61,6 +64,21 @@
editor.apply();
}
+ public void storeWifi(Set<String> paidSsids, Set<String> privateSsids) {
+ SharedPreferences.Editor editor = mSharedPrefs.edit();
+ editor.putStringSet(KEY_OEM_PAID_WIFI_SSIDS, paidSsids);
+ editor.putStringSet(KEY_OEM_PRIVATE_WIFI_SSIDS, privateSsids);
+ editor.apply();
+ }
+
+ public Set<String> getOemPaidWifiSsids() {
+ return mSharedPrefs.getStringSet(KEY_OEM_PAID_WIFI_SSIDS, new HashSet<String>());
+ }
+
+ public Set<String> getOemPrivateWifiSsids() {
+ return mSharedPrefs.getStringSet(KEY_OEM_PRIVATE_WIFI_SSIDS, new HashSet<String>());
+ }
+
public void saveReapplyPansOnBootCompleteState(boolean checked) {
SharedPreferences.Editor editor = mSharedPrefs.edit();
editor.putBoolean(KEY_REAPPLY_PANS_ON_BOOT_COMPLETE, checked);
diff --git a/tests/NetworkPreferenceApp/src/com/google/android/car/networking/preferenceupdater/fragments/ManagerFragment.java b/tests/NetworkPreferenceApp/src/com/google/android/car/networking/preferenceupdater/fragments/ManagerFragment.java
index beb2de6..3ffb851 100644
--- a/tests/NetworkPreferenceApp/src/com/google/android/car/networking/preferenceupdater/fragments/ManagerFragment.java
+++ b/tests/NetworkPreferenceApp/src/com/google/android/car/networking/preferenceupdater/fragments/ManagerFragment.java
@@ -23,6 +23,9 @@
import android.content.Context;
import android.net.NetworkIdentity;
import android.net.NetworkTemplate;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.net.wifi.WifiNetworkSuggestion;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -33,8 +36,9 @@
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.Switch;
import android.widget.TextView;
-import android.widget.ToggleButton;
+import android.widget.Toast;
import androidx.fragment.app.Fragment;
@@ -45,6 +49,7 @@
import com.google.android.car.networking.preferenceupdater.components.PersonalStorage;
import com.google.android.car.networking.preferenceupdater.utils.Utils;
+import java.util.ArrayList;
import java.util.Set;
public final class ManagerFragment extends Fragment {
@@ -57,6 +62,7 @@
private PersonalStorage mPersonalStorage;
private OemNetworkPreferencesAdapter mOemNetworkPreferencesAdapter;
private CarDriverDistractionManagerAdapter mCarDriverDistractionManagerAdapter;
+ private WifiManager mWifiManager;
// Metric Display components
private MetricDisplay mMetricDisplay;
@@ -84,9 +90,14 @@
private EditText mOEMPaidOnlyAppsEditText;
private EditText mOEMPrivateOnlyAppsEditText;
private TextView mCurrentPANSStatusTextView;
- private ToggleButton mReapplyPANSOnBootToggleButton;
+ private Switch mReapplyPANSOnBootSwitch;
private Button mApplyConfigurationBtn;
private Button mResetNetworkPreferencesBtn;
+ private Button mApplyWifiCapabilitiesBtn;
+
+ // Wifi SSIDs
+ private EditText mOEMPaidWifiSSIDsEditText;
+ private EditText mOEMPrivateWifiSSIDsEditText;
@Override
public View onCreateView(
@@ -110,6 +121,8 @@
// Let's start watching OEM traffic and updating indicators
mMetricDisplay.startWatching();
+ mWifiManager = context.getSystemService(WifiManager.class);
+
return v;
}
@@ -126,10 +139,13 @@
mOEMPaidNoFallbackAppsEditText = v.findViewById(R.id.OEMPaidNoFallbackAppsEditText);
mOEMPaidOnlyAppsEditText = v.findViewById(R.id.OEMPaidOnlyAppsEditText);
mOEMPrivateOnlyAppsEditText = v.findViewById(R.id.OEMPrivateOnlyAppsEditText);
+ mOEMPaidWifiSSIDsEditText = v.findViewById(R.id.OEMPaidWifiSSIDsEditText);
+ mOEMPrivateWifiSSIDsEditText = v.findViewById(R.id.OEMPrivateWifiSSIDsEditText);
mCurrentPANSStatusTextView = v.findViewById(R.id.currentPANSStatusTextView);
- mReapplyPANSOnBootToggleButton = v.findViewById(R.id.reapplyPANSOnBootToggleButton);
+ mReapplyPANSOnBootSwitch = v.findViewById(R.id.reapplyPANSOnBootSwitch);
mApplyConfigurationBtn = v.findViewById(R.id.applyConfigurationBtn);
mResetNetworkPreferencesBtn = v.findViewById(R.id.resetNetworkPreferencesBtn);
+ mApplyWifiCapabilitiesBtn = v.findViewById(R.id.applyWifiCapabilitiesButton);
// Since our Metric Display is going to be alive, we want to pass our TextView components
// into MetricDisplay instance to simplify refresh logic.
mOemPaidRxBytesTextView = v.findViewById(R.id.oemPaidRxBytesTextView);
@@ -144,16 +160,16 @@
private void updateMetricIndicatorByType(int type, long tx, long rx) {
switch (type) {
case NetworkIdentity.OEM_PAID:
- mOemPaidTxBytesTextView.setText("" + tx);
- mOemPaidRxBytesTextView.setText("" + rx);
+ mOemPaidTxBytesTextView.setText(String.valueOf(tx));
+ mOemPaidRxBytesTextView.setText(String.valueOf(rx));
break;
case NetworkIdentity.OEM_PRIVATE:
- mOemPrivateTxBytesTextView.setText("" + tx);
- mOemPrivateRxBytesTextView.setText("" + rx);
+ mOemPrivateTxBytesTextView.setText(String.valueOf(tx));
+ mOemPrivateRxBytesTextView.setText(String.valueOf(rx));
break;
case NetworkTemplate.OEM_MANAGED_YES:
- mOemTotalTxBytesTextView.setText("" + tx);
- mOemTotalRxBytesTextView.setText("" + rx);
+ mOemTotalTxBytesTextView.setText(String.valueOf(tx));
+ mOemTotalRxBytesTextView.setText(String.valueOf(rx));
break;
default:
Log.e(TAG, "Unknown NetworkIdentity " + type);
@@ -163,7 +179,8 @@
/** Defines actions of the buttons on the page */
private void defineButtonActions() {
mApplyConfigurationBtn.setOnClickListener(view -> onApplyConfigurationBtnClick());
- mReapplyPANSOnBootToggleButton.setOnCheckedChangeListener(
+ mApplyWifiCapabilitiesBtn.setOnClickListener(view -> onApplyWifiCapabilitiesBtnClick());
+ mReapplyPANSOnBootSwitch.setOnCheckedChangeListener(
(buttonView, isChecked) ->
mPersonalStorage.saveReapplyPansOnBootCompleteState(true));
mResetNetworkPreferencesBtn.setOnClickListener(view -> resetNetworkPreferences());
@@ -183,8 +200,10 @@
mOEMPaidOnlyAppsEditText.setText(getFromStorage(OEM_NETWORK_PREFERENCE_OEM_PAID_ONLY));
mOEMPrivateOnlyAppsEditText.setText(
getFromStorage(OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY));
- mReapplyPANSOnBootToggleButton.setChecked(
- mPersonalStorage.getReapplyPansOnBootCompleteState());
+ mReapplyPANSOnBootSwitch.setChecked(mPersonalStorage.getReapplyPansOnBootCompleteState());
+ mOEMPaidWifiSSIDsEditText.setText(Utils.toString(mPersonalStorage.getOemPaidWifiSsids()));
+ mOEMPrivateWifiSSIDsEditText.setText(
+ Utils.toString(mPersonalStorage.getOemPrivateWifiSsids()));
}
private String getFromStorage(int type) {
@@ -198,8 +217,43 @@
mCurrentPANSStatusTextView.setText(status ? "Yes" : "No");
}
+ private void onApplyWifiCapabilitiesBtnClick() {
+ Log.d(TAG, "Applying WiFi settings");
+ Set<String> ssidsWithOemPaid = Utils.toSet(mOEMPaidWifiSSIDsEditText.getText().toString());
+ Set<String> ssidsWithOemPrivate =
+ Utils.toSet(mOEMPrivateWifiSSIDsEditText.getText().toString());
+
+ try {
+ ArrayList<WifiNetworkSuggestion> list = new ArrayList<>();
+ for (String ssid : ssidsWithOemPaid) {
+ list.add(
+ new WifiNetworkSuggestion.Builder()
+ .setSsid(WifiInfo.sanitizeSsid(ssid))
+ .setOemPaid(true)
+ .build());
+ }
+
+ for (String ssid : ssidsWithOemPrivate) {
+ list.add(
+ new WifiNetworkSuggestion.Builder()
+ .setSsid(WifiInfo.sanitizeSsid(ssid))
+ .setOemPrivate(true)
+ .build());
+ }
+
+ mWifiManager.removeNetworkSuggestions(new ArrayList<>());
+ mWifiManager.addNetworkSuggestions(list);
+ } catch (Exception e) {
+ // Could not set Wifi capabilities, pop the toast and do nothing
+ Log.e(TAG, "Failed to set Wifi capabilities", e);
+ Toast.makeText(getActivity(), e.toString(), Toast.LENGTH_SHORT).show();
+ return;
+ }
+ mPersonalStorage.storeWifi(ssidsWithOemPaid, ssidsWithOemPrivate);
+ }
+
private void onApplyConfigurationBtnClick() {
- Log.i(TAG, "[NetworkPreferenceApp] PANS Policy was applied!");
+ Log.d(TAG, "Applying PANS");
// First we want to make sure that we are allowed to change
if (!mCarDriverDistractionManagerAdapter.allowedToBeDistracted()) {
// We are not allowed to apply PANS changes. Do nothing.