Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7929ab9e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Refine WifiWakeupPreferenceController"

parents fc9109c4 0e570cd2
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -109,11 +109,11 @@ public class WifiWakeupPreferenceController extends TogglePreferenceController i
    @Override
    public boolean setChecked(boolean isChecked) {
        if (isChecked) {
            if (!getLocationEnabled()) {
                if (mFragment == null) {
                    throw new IllegalStateException("No fragment to start activity");
                }

            if (!getLocationEnabled()) {
                final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                mFragment.startActivityForResult(intent, WIFI_WAKEUP_REQUEST_CODE);
                return false;
+12 −0
Original line number Diff line number Diff line
@@ -94,6 +94,18 @@ public class WifiWakeupPreferenceControllerTest {
        assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
    }

    @Test
    public void setChecked_mFragmentIsNullLocationEnable_wifiWakeupEnable() {
        mController.setFragment(null);
        when(mLocationManager.isLocationEnabled()).thenReturn(true);
        when(mWifiManager.isScanAlwaysAvailable()).thenReturn(true);
        when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);

        mController.setChecked(true);

        verify(mWifiManager).setAutoWakeupEnabled(true);
    }

    @Test
    public void setChecked_scanEnableLocationEnable_wifiWakeupEnable() {
        when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);