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
This commit is contained in:
Amin Shaikh
2017-05-09 13:41:35 -07:00
parent dfa9bb8914
commit a5cf6fbf37
2 changed files with 6 additions and 13 deletions

View File

@@ -100,13 +100,11 @@ public class NotifyOpenNetworksPreferenceController extends PreferenceController
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 class NotifyOpenNetworksPreferenceController extends PreferenceController
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 @@ public class NotifyOpenNetworksPreferenceController extends PreferenceController
@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);
}
}

View File

@@ -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 @@ public class NotifyOpenNetworkPreferenceControllerTest {
}
@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);
}
}