diff --git a/res/values/strings.xml b/res/values/strings.xml
index f6f4d5af059..d8d442c441f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1451,10 +1451,12 @@
Always allow scanning
Let Google\'s location service and other apps scan for networks, even when Wi\u2011Fi is off
-
- Automatically manage Wi\u2011Fi
-
- Let %1$s manage your Wi\u2011Fi connection
+
+ Connect to open Wi\u2011Fi automatically
+
+ Allow a Wi\u2011Fi assistant to automatically rate and connect to open Wi\u2011Fi networks determined to be high quality
+
+ Select a Wi\u2011Fi assistant
Install certificates
To improve location accuracy and for other purposes, Google and other apps may scan for nearby networks, even when Wi-Fi is off. If you don\'t want this to happen, go to Advanced > Scanning always available.
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 0e83d90c467..162dced3f53 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -312,6 +312,10 @@
- @layout/apn_preference_layout
+
+
@@ -341,5 +345,4 @@
-
diff --git a/res/xml/wifi_advanced_settings.xml b/res/xml/wifi_advanced_settings.xml
index 5b81d255ee2..a7f47b1db7c 100644
--- a/res/xml/wifi_advanced_settings.xml
+++ b/res/xml/wifi_advanced_settings.xml
@@ -30,11 +30,6 @@
android:summary="@string/wifi_scan_always_available_summary"
android:persistent="false" />
-
-
+
+
scorers =
+ NetworkScorerAppManager.getAllValidScorers(context);
+ if (UserHandle.myUserId() == UserHandle.USER_OWNER && !scorers.isEmpty()) {
+ mWifiAssistantPreference.setOnPreferenceChangeListener(this);
+ initWifiAssistantPreference(scorers);
+ } else if (mWifiAssistantPreference != null) {
+ getPreferenceScreen().removePreference(mWifiAssistantPreference);
}
Intent wifiDirectIntent = new Intent(context,
@@ -202,6 +200,18 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
}
}
+ private void initWifiAssistantPreference(Collection scorers) {
+ int count = scorers.size();
+ String[] packageNames = new String[count];
+ int i = 0;
+ for (NetworkScorerAppData scorer : scorers) {
+ packageNames[i] = scorer.mPackageName;
+ i++;
+ }
+ mWifiAssistantPreference.setPackageNames(packageNames,
+ mNetworkScoreManager.getActiveScorerPackage());
+ }
+
private void updateSleepPolicySummary(Preference sleepPolicyPref, String value) {
if (value != null) {
String[] values = getResources().getStringArray(R.array.wifi_sleep_policy_values);
@@ -261,12 +271,13 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
return false;
}
} else if (KEY_WIFI_ASSISTANT.equals(key)) {
- if (((Boolean)newValue).booleanValue() == false) {
+ NetworkScorerAppData wifiAssistant =
+ NetworkScorerAppManager.getScorer(context, (String) newValue);
+ if (wifiAssistant == null) {
mNetworkScoreManager.setActiveScorer(null);
return true;
}
- NetworkScorerAppData wifiAssistant = getWifiAssistantApp(context);
Intent intent = new Intent();
if (wifiAssistant.mConfigurationActivityClassName != null) {
// App has a custom configuration activity; launch that.
@@ -282,6 +293,9 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
}
startActivity(intent);
+ // Don't update the preference widget state until the child activity returns.
+ // It will be updated in onResume after the activity finishes.
+ return false;
}
if (KEY_SLEEP_POLICY.equals(key)) {
@@ -317,22 +331,6 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
wifiIpAddressPref.setSelectable(false);
}
- /**
- * Returns the Network Scorer for the Wifi Assistant App.
- */
- public static NetworkScorerAppData getWifiAssistantApp(Context context) {
- Collection scorers =
- NetworkScorerAppManager.getAllValidScorers(context);
-
- if (scorers.isEmpty()) {
- return null;
- }
-
- // TODO: b/13780935 - Implement proper scorer selection. Rather than pick the first
- // scorer on the system, we should allow the user to select one.
- return scorers.iterator().next();
- }
-
/* Wrapper class for the WPS dialog to properly handle life cycle events like rotation. */
public static class WpsFragment extends DialogFragment {
private static int mWpsSetup;