Fix "Turn on Wi-Fi scanning?" does not pop up when clicking "Turn on Wi-Fi automatically"
We should make sure both 'Use location' & 'Wi-Fi scanning' are enabled before calling setWifiWakeupEnabled. Bug: 131777439 Test: manual Change-Id: I602917cfa7c5581ecb414e8c44b4e20c8f9ea78d
This commit is contained in:
@@ -22,6 +22,7 @@ import static android.provider.Settings.Global.WIFI_WAKEUP_ENABLED;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.LocationManager;
|
||||
@@ -95,6 +96,19 @@ public class WifiWakeupPreferenceControllerTest {
|
||||
.isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlePreferenceTreeClick_wifiWakeupEnableScanningDisable_wifiWakeupEnable() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
|
||||
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 0);
|
||||
doReturn(true).when(mLocationManager).isLocationEnabled();
|
||||
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
final boolean isWifiWakeupEnabled = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.WIFI_WAKEUP_ENABLED, 0) == 1;
|
||||
|
||||
assertThat(isWifiWakeupEnabled).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_preferenceSetCheckedWhenWakeupSettingEnabled() {
|
||||
final SwitchPreference preference = new SwitchPreference(mContext);
|
||||
|
Reference in New Issue
Block a user