Hide toggle to Turn on Wi-Fi automatically preference in Search settings
- If the location setting is enabled, keep the current design. that the user can switch the toggle directly in the search settings to the "Turn on Wi-Fi automatically" toggle preference. - If the location setting is disabled, hide the switch toggle to "Turn on Wi-Fi automatically" preference to avoid unexpected behavior. - The user can click the "Turn on Wi-Fi automatically" preference to jump to the Network preference settings, and see a reminder message in the summary to enable the location settings first before switching the toggle. Bug: 235421460 Test: manual test make RunSettingsRoboTests ROBOTEST_FILTER=WifiWakeupPreferenceControllerTest Change-Id: Ib2c6b90308606d32179334d13be91e308971084f
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.settings.wifi;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -68,6 +71,29 @@ public class WifiWakeupPreferenceControllerTest {
|
||||
doReturn(true).when(mLocationManager).isLocationEnabled();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_fragmentIsNotNull_returnAvailable() {
|
||||
mController.setFragment(mFragment);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_fragmentIsNullAndLocationDisabled_returnDisabled() {
|
||||
mController.setFragment(null);
|
||||
when(mLocationManager.isLocationEnabled()).thenReturn(false);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_fragmentIsNullAndWifiScanDisabled_returnDisabled() {
|
||||
mController.setFragment(null);
|
||||
when(mWifiManager.isScanAlwaysAvailable()).thenReturn(false);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_scanEnableLocationEnable_wifiWakeupEnable() {
|
||||
when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);
|
||||
|
Reference in New Issue
Block a user