Update "Open networks available" setting.
- Remove gating ONA toggle on whether network recommendations are
enabled. It is always on and provided by the wifi framework.
Bug: 37794067
Test: m RunSettingsRoboTests && tested locally
Change-Id: I312858d50b348bbe829538d4fa337b2072cb2043
diff --git a/src/com/android/settings/wifi/NotifyOpenNetworksPreferenceController.java b/src/com/android/settings/wifi/NotifyOpenNetworksPreferenceController.java
index 8771da4..6e88d79 100644
--- a/src/com/android/settings/wifi/NotifyOpenNetworksPreferenceController.java
+++ b/src/com/android/settings/wifi/NotifyOpenNetworksPreferenceController.java
@@ -100,13 +100,11 @@
final SwitchPreference notifyOpenNetworks = (SwitchPreference) preference;
notifyOpenNetworks.setChecked(Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
- notifyOpenNetworks.setEnabled(Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0) == 1);
}
class SettingObserver extends ContentObserver {
- private final Uri NETWORK_RECOMMENDATIONS_ENABLED_URI =
- Settings.Global.getUriFor(Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED);
+ private final Uri NETWORKS_AVAILABLE_URI = Settings.Global.getUriFor(
+ Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
private final Preference mPreference;
@@ -117,7 +115,7 @@
public void register(ContentResolver cr, boolean register) {
if (register) {
- cr.registerContentObserver(NETWORK_RECOMMENDATIONS_ENABLED_URI, false, this);
+ cr.registerContentObserver(NETWORKS_AVAILABLE_URI, false, this);
} else {
cr.unregisterContentObserver(this);
}
@@ -126,7 +124,7 @@
@Override
public void onChange(boolean selfChange, Uri uri) {
super.onChange(selfChange, uri);
- if (NETWORK_RECOMMENDATIONS_ENABLED_URI.equals(uri)) {
+ if (NETWORKS_AVAILABLE_URI.equals(uri)) {
updateState(mPreference);
}
}
diff --git a/tests/robotests/src/com/android/settings/wifi/NotifyOpenNetworkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/NotifyOpenNetworkPreferenceControllerTest.java
index 3afa7fb..75b304e 100644
--- a/tests/robotests/src/com/android/settings/wifi/NotifyOpenNetworkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NotifyOpenNetworkPreferenceControllerTest.java
@@ -16,7 +16,6 @@
package com.android.settings.wifi;
-import static android.provider.Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED;
import static android.provider.Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
import static com.google.common.truth.Truth.assertThat;
@@ -87,28 +86,24 @@
}
@Test
- public void updateState_preferenceSetCheckedAndSetEnabledWhenSettingsAreEnabled() {
+ public void updateState_preferenceSetCheckedWhenSettingsAreEnabled() {
final SwitchPreference preference = mock(SwitchPreference.class);
- Settings.System.putInt(mContext.getContentResolver(), NETWORK_RECOMMENDATIONS_ENABLED, 1);
Settings.System.putInt(mContext.getContentResolver(),
WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1);
mController.updateState(preference);
verify(preference).setChecked(true);
- verify(preference).setEnabled(true);
}
@Test
- public void updateState_preferenceSetCheckedAndSetEnabledWhenSettingsAreDisabled() {
+ public void updateState_preferenceSetCheckedWhenSettingsAreDisabled() {
final SwitchPreference preference = mock(SwitchPreference.class);
- Settings.System.putInt(mContext.getContentResolver(), NETWORK_RECOMMENDATIONS_ENABLED, 0);
Settings.System.putInt(mContext.getContentResolver(),
WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0);
mController.updateState(preference);
verify(preference).setChecked(false);
- verify(preference).setEnabled(false);
}
}