Merge "AOD: Add temporary always-on setting"
This commit is contained in:
@@ -2392,6 +2392,10 @@
|
|||||||
<string name="doze_title">Ambient display</string>
|
<string name="doze_title">Ambient display</string>
|
||||||
<!-- [CHAR LIMIT=NONE] Display settings screen, setting description for the ambient display feature. -->
|
<!-- [CHAR LIMIT=NONE] Display settings screen, setting description for the ambient display feature. -->
|
||||||
<string name="doze_summary">Wake screen when you receive notifications</string>
|
<string name="doze_summary">Wake screen when you receive notifications</string>
|
||||||
|
<!-- [CHAR LIMIT=30] Display settings screen, setting option name to change whether the always-on ambient display feature is enabled. -->
|
||||||
|
<string name="doze_always_on_title">Always on</string>
|
||||||
|
<!-- [CHAR LIMIT=NONE] Display settings screen, setting description for the always-on ambient display feature. -->
|
||||||
|
<string name="doze_always_on_summary">Show time, notification icons, and other info</string>
|
||||||
<!-- [CHAR LIMIT=30] Sound & display settings screen, setting option name to change font size -->
|
<!-- [CHAR LIMIT=30] Sound & display settings screen, setting option name to change font size -->
|
||||||
<string name="title_font_size">Font size</string>
|
<string name="title_font_size">Font size</string>
|
||||||
<!-- Summary for Font size. Lets the user know that this will make text larger or smaller. Appears in the accessibility portion of setup wizard. [CHAR LIMIT=NONE] -->
|
<!-- Summary for Font size. Lets the user know that this will make text larger or smaller. Appears in the accessibility portion of setup wizard. [CHAR LIMIT=NONE] -->
|
||||||
|
|||||||
@@ -110,6 +110,11 @@
|
|||||||
android:title="@string/doze_title"
|
android:title="@string/doze_title"
|
||||||
android:summary="@string/doze_summary" />
|
android:summary="@string/doze_summary" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="doze_always_on"
|
||||||
|
android:title="@string/doze_always_on_title"
|
||||||
|
android:summary="@string/doze_always_on_summary" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="tap_to_wake"
|
android:key="tap_to_wake"
|
||||||
android:title="@string/tap_to_wake"
|
android:title="@string/tap_to_wake"
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import com.android.settings.display.AutoBrightnessPreferenceController;
|
|||||||
import com.android.settings.display.AutoRotatePreferenceController;
|
import com.android.settings.display.AutoRotatePreferenceController;
|
||||||
import com.android.settings.display.BrightnessLevelPreferenceController;
|
import com.android.settings.display.BrightnessLevelPreferenceController;
|
||||||
import com.android.settings.display.CameraGesturePreferenceController;
|
import com.android.settings.display.CameraGesturePreferenceController;
|
||||||
|
import com.android.settings.display.DozeAlwaysOnPreferenceController;
|
||||||
import com.android.settings.display.DozePreferenceController;
|
import com.android.settings.display.DozePreferenceController;
|
||||||
import com.android.settings.display.FontSizePreferenceController;
|
import com.android.settings.display.FontSizePreferenceController;
|
||||||
import com.android.settings.display.LiftToWakePreferenceController;
|
import com.android.settings.display.LiftToWakePreferenceController;
|
||||||
@@ -42,6 +43,7 @@ import com.android.settings.display.VrDisplayPreferenceController;
|
|||||||
import com.android.settings.display.WallpaperPreferenceController;
|
import com.android.settings.display.WallpaperPreferenceController;
|
||||||
import com.android.settings.gestures.DoubleTapScreenPreferenceController;
|
import com.android.settings.gestures.DoubleTapScreenPreferenceController;
|
||||||
import com.android.settings.gestures.PickupGesturePreferenceController;
|
import com.android.settings.gestures.PickupGesturePreferenceController;
|
||||||
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.Indexable;
|
import com.android.settings.search.Indexable;
|
||||||
|
|
||||||
@@ -90,16 +92,18 @@ public class DisplaySettings extends DashboardFragment {
|
|||||||
private static List<PreferenceController> buildPreferenceControllers(
|
private static List<PreferenceController> buildPreferenceControllers(
|
||||||
Context context, Lifecycle lifecycle) {
|
Context context, Lifecycle lifecycle) {
|
||||||
final List<PreferenceController> controllers = new ArrayList<>();
|
final List<PreferenceController> controllers = new ArrayList<>();
|
||||||
|
final AmbientDisplayConfiguration ambientDisplayConfig = new AmbientDisplayConfiguration(context);
|
||||||
controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS));
|
controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS));
|
||||||
controllers.add(new AutoRotatePreferenceController(context, lifecycle));
|
controllers.add(new AutoRotatePreferenceController(context, lifecycle));
|
||||||
controllers.add(new CameraGesturePreferenceController(context));
|
controllers.add(new CameraGesturePreferenceController(context));
|
||||||
controllers.add(new DozePreferenceController(context));
|
controllers.add(new DozePreferenceController(context, ambientDisplayConfig,
|
||||||
|
FeatureFactory.getFactory(context).getMetricsFeatureProvider()));
|
||||||
|
controllers.add(new DozeAlwaysOnPreferenceController(context, ambientDisplayConfig));
|
||||||
controllers.add(new FontSizePreferenceController(context));
|
controllers.add(new FontSizePreferenceController(context));
|
||||||
controllers.add(new LiftToWakePreferenceController(context));
|
controllers.add(new LiftToWakePreferenceController(context));
|
||||||
controllers.add(new NightDisplayPreferenceController(context));
|
controllers.add(new NightDisplayPreferenceController(context));
|
||||||
controllers.add(new NightModePreferenceController(context));
|
controllers.add(new NightModePreferenceController(context));
|
||||||
controllers.add(new ScreenSaverPreferenceController(context));
|
controllers.add(new ScreenSaverPreferenceController(context));
|
||||||
AmbientDisplayConfiguration ambientDisplayConfig = new AmbientDisplayConfiguration(context);
|
|
||||||
controllers.add(new PickupGesturePreferenceController(
|
controllers.add(new PickupGesturePreferenceController(
|
||||||
context, lifecycle, ambientDisplayConfig, UserHandle.myUserId()));
|
context, lifecycle, ambientDisplayConfig, UserHandle.myUserId()));
|
||||||
controllers.add(new DoubleTapScreenPreferenceController(
|
controllers.add(new DoubleTapScreenPreferenceController(
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.android.settings.display;
|
||||||
|
|
||||||
|
import static android.provider.Settings.Secure.DOZE_ALWAYS_ON;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.support.v14.preference.SwitchPreference;
|
||||||
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
|
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||||
|
import com.android.settings.core.PreferenceController;
|
||||||
|
|
||||||
|
public class DozeAlwaysOnPreferenceController extends PreferenceController implements
|
||||||
|
Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
|
private static final String KEY_DOZE_ALWAYS_ON = "doze_always_on";
|
||||||
|
private static final int MY_USER = UserHandle.myUserId();
|
||||||
|
|
||||||
|
private final AmbientDisplayConfiguration mConfig;
|
||||||
|
|
||||||
|
public DozeAlwaysOnPreferenceController(Context context, AmbientDisplayConfiguration config) {
|
||||||
|
super(context);
|
||||||
|
mConfig = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPreferenceKey() {
|
||||||
|
return KEY_DOZE_ALWAYS_ON;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateState(Preference preference) {
|
||||||
|
((SwitchPreference) preference).setChecked(mConfig.alwaysOnEnabled(MY_USER));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
int enabled = (boolean) newValue ? 1 : 0;
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(), DOZE_ALWAYS_ON, enabled);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAvailable() {
|
||||||
|
return mConfig.alwaysOnAvailable();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,16 +14,15 @@
|
|||||||
package com.android.settings.display;
|
package com.android.settings.display;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.UserHandle;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.support.annotation.VisibleForTesting;
|
||||||
import android.support.v14.preference.SwitchPreference;
|
import android.support.v14.preference.SwitchPreference;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
|
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||||
import com.android.settings.core.PreferenceController;
|
import com.android.settings.core.PreferenceController;
|
||||||
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.DOZE_ENABLED;
|
import static android.provider.Settings.Secure.DOZE_ENABLED;
|
||||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_AMBIENT_DISPLAY;
|
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_AMBIENT_DISPLAY;
|
||||||
@@ -31,13 +30,18 @@ import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION
|
|||||||
public class DozePreferenceController extends PreferenceController implements
|
public class DozePreferenceController extends PreferenceController implements
|
||||||
Preference.OnPreferenceChangeListener {
|
Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
private static final String KEY_DOZE = "doze";
|
@VisibleForTesting
|
||||||
|
static final String KEY_DOZE = "doze";
|
||||||
|
private static final int MY_USER = UserHandle.myUserId();
|
||||||
|
|
||||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||||
|
private final AmbientDisplayConfiguration mConfig;
|
||||||
|
|
||||||
public DozePreferenceController(Context context) {
|
public DozePreferenceController(Context context, AmbientDisplayConfiguration config,
|
||||||
|
MetricsFeatureProvider metricsFeatureProvider) {
|
||||||
super(context);
|
super(context);
|
||||||
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
mMetricsFeatureProvider = metricsFeatureProvider;
|
||||||
|
mConfig = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,8 +59,7 @@ public class DozePreferenceController extends PreferenceController implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
int value = Settings.Secure.getInt(mContext.getContentResolver(), DOZE_ENABLED, 1);
|
((SwitchPreference) preference).setChecked(mConfig.pulseOnNotificationEnabled(MY_USER));
|
||||||
((SwitchPreference) preference).setChecked(value != 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,11 +71,6 @@ public class DozePreferenceController extends PreferenceController implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
String name = Build.IS_DEBUGGABLE ? SystemProperties.get("debug.doze.component") : null;
|
return mConfig.pulseOnNotificationAvailable();
|
||||||
if (TextUtils.isEmpty(name)) {
|
|
||||||
name = mContext.getResources().getString(
|
|
||||||
com.android.internal.R.string.config_dozeComponent);
|
|
||||||
}
|
|
||||||
return !TextUtils.isEmpty(name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.internal.hardware;
|
package com.android.internal.hardware;
|
||||||
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,4 +41,20 @@ public class AmbientDisplayConfiguration {
|
|||||||
public boolean pulseOnDoubleTapEnabled(int user) {
|
public boolean pulseOnDoubleTapEnabled(int user) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean pulseOnNotificationEnabled(int user) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean pulseOnNotificationAvailable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean alwaysOnEnabled(int user) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean alwaysOnAvailable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.display;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Matchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.support.v14.preference.SwitchPreference;
|
||||||
|
|
||||||
|
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||||
|
import com.android.settings.SettingsRobolectricTestRunner;
|
||||||
|
import com.android.settings.TestConfig;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowSecureSettings;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
||||||
|
shadows = {ShadowSecureSettings.class})
|
||||||
|
public class DozeAlwaysOnPreferenceControllerTest {
|
||||||
|
|
||||||
|
@Mock Context mContext;
|
||||||
|
@Mock AmbientDisplayConfiguration mConfig;
|
||||||
|
@Mock SwitchPreference mSwitchPreference;
|
||||||
|
|
||||||
|
DozeAlwaysOnPreferenceController mController;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mController = new DozeAlwaysOnPreferenceController(mContext, mConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_enabled() throws Exception {
|
||||||
|
when(mConfig.alwaysOnEnabled(anyInt()))
|
||||||
|
.thenReturn(true);
|
||||||
|
|
||||||
|
mController.updateState(mSwitchPreference);
|
||||||
|
|
||||||
|
verify(mSwitchPreference).setChecked(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_disabled() throws Exception {
|
||||||
|
when(mConfig.alwaysOnEnabled(anyInt()))
|
||||||
|
.thenReturn(false);
|
||||||
|
|
||||||
|
mController.updateState(mSwitchPreference);
|
||||||
|
|
||||||
|
verify(mSwitchPreference).setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onPreferenceChange_enable() throws Exception {
|
||||||
|
mController.onPreferenceChange(mSwitchPreference, true);
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(null, Settings.Secure.DOZE_ALWAYS_ON, -1))
|
||||||
|
.isEqualTo(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onPreferenceChange_disable() throws Exception {
|
||||||
|
mController.onPreferenceChange(mSwitchPreference, false);
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(null, Settings.Secure.DOZE_ALWAYS_ON, -1))
|
||||||
|
.isEqualTo(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_available() throws Exception {
|
||||||
|
when(mConfig.alwaysOnAvailable())
|
||||||
|
.thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_unavailable() throws Exception {
|
||||||
|
when(mConfig.alwaysOnAvailable())
|
||||||
|
.thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.display;
|
||||||
|
|
||||||
|
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_AMBIENT_DISPLAY;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Matchers.any;
|
||||||
|
import static org.mockito.Matchers.anyInt;
|
||||||
|
import static org.mockito.Matchers.eq;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.support.v14.preference.SwitchPreference;
|
||||||
|
|
||||||
|
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||||
|
import com.android.settings.SettingsRobolectricTestRunner;
|
||||||
|
import com.android.settings.TestConfig;
|
||||||
|
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowSecureSettings;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
||||||
|
shadows = {ShadowSecureSettings.class})
|
||||||
|
public class DozePreferenceControllerTest {
|
||||||
|
|
||||||
|
@Mock Context mContext;
|
||||||
|
@Mock AmbientDisplayConfiguration mConfig;
|
||||||
|
@Mock SwitchPreference mSwitchPreference;
|
||||||
|
@Mock MetricsFeatureProvider mMetricsFeatureProvider;
|
||||||
|
|
||||||
|
DozePreferenceController mController;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mController = new DozePreferenceController(mContext, mConfig, mMetricsFeatureProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_enabled() throws Exception {
|
||||||
|
when(mConfig.pulseOnNotificationEnabled(anyInt()))
|
||||||
|
.thenReturn(true);
|
||||||
|
|
||||||
|
mController.updateState(mSwitchPreference);
|
||||||
|
|
||||||
|
verify(mSwitchPreference).setChecked(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_disabled() throws Exception {
|
||||||
|
when(mConfig.pulseOnNotificationEnabled(anyInt()))
|
||||||
|
.thenReturn(false);
|
||||||
|
|
||||||
|
mController.updateState(mSwitchPreference);
|
||||||
|
|
||||||
|
verify(mSwitchPreference).setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onPreferenceChange_enable() throws Exception {
|
||||||
|
mController.onPreferenceChange(mSwitchPreference, true);
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(null, Settings.Secure.DOZE_ENABLED, -1))
|
||||||
|
.isEqualTo(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onPreferenceChange_disable() throws Exception {
|
||||||
|
mController.onPreferenceChange(mSwitchPreference, false);
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(null, Settings.Secure.DOZE_ENABLED, -1))
|
||||||
|
.isEqualTo(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_available() throws Exception {
|
||||||
|
when(mConfig.pulseOnNotificationAvailable())
|
||||||
|
.thenReturn(true);
|
||||||
|
|
||||||
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_unavailable() throws Exception {
|
||||||
|
when(mConfig.pulseOnNotificationAvailable())
|
||||||
|
.thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void handlePreferenceTreeClick_reportsEventForItsPreference() throws Exception {
|
||||||
|
when(mSwitchPreference.getKey()).thenReturn(DozePreferenceController.KEY_DOZE);
|
||||||
|
|
||||||
|
mController.handlePreferenceTreeClick(mSwitchPreference);
|
||||||
|
|
||||||
|
verify(mMetricsFeatureProvider).action(any(), eq(ACTION_AMBIENT_DISPLAY));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void handlePreferenceTreeClick_doesntReportEventForOtherPreferences() throws Exception {
|
||||||
|
when(mSwitchPreference.getKey()).thenReturn("some_other_key");
|
||||||
|
|
||||||
|
mController.handlePreferenceTreeClick(mSwitchPreference);
|
||||||
|
|
||||||
|
verifyNoMoreInteractions(mMetricsFeatureProvider);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -259,7 +259,7 @@ public class DatabaseIndexingManagerTest {
|
|||||||
SearchIndexableResource resource = getFakeResource(R.xml.display_settings);
|
SearchIndexableResource resource = getFakeResource(R.xml.display_settings);
|
||||||
mManager.indexOneSearchIndexableData(mDb, localeStr, resource, new HashMap<>());
|
mManager.indexOneSearchIndexableData(mDb, localeStr, resource, new HashMap<>());
|
||||||
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index", null);
|
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index", null);
|
||||||
assertThat(cursor.getCount()).isEqualTo(18);
|
assertThat(cursor.getCount()).isEqualTo(19);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -274,7 +274,7 @@ public class DatabaseIndexingManagerTest {
|
|||||||
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE enabled = 0", null);
|
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE enabled = 0", null);
|
||||||
assertThat(cursor.getCount()).isEqualTo(2);
|
assertThat(cursor.getCount()).isEqualTo(2);
|
||||||
cursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE enabled = 1", null);
|
cursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE enabled = 1", null);
|
||||||
assertThat(cursor.getCount()).isEqualTo(16);
|
assertThat(cursor.getCount()).isEqualTo(17);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user