settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController" />
<Preference
+ android:key="ambient_display_wake_screen"
+ android:title="@string/ambient_display_wake_screen_title"
+ android:fragment="com.android.settings.gestures.WakeScreenGestureSettings"
+ settings:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController" />
+
+ <Preference
android:key="ambient_display_tap"
android:title="@string/ambient_display_tap_screen_title"
android:fragment="com.android.settings.gestures.TapScreenGestureSettings"
android:fragment="com.android.settings.gestures.PickupGestureSettings"
settings:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
- <Preference
- android:key="ambient_display_wake_screen"
- android:title="@string/ambient_display_wake_screen_title"
- android:fragment="com.android.settings.gestures.WakeScreenGestureSettings"
- settings:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController" />
-
<SwitchPreference
android:key="ambient_display_notification"
android:title="@string/doze_title"
|| !mFeatureProvider.isSupported(mContext)) {
return UNSUPPORTED_ON_DEVICE;
}
- return mFeatureProvider.isEnabled(mContext) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+
+ if (!mFeatureProvider.isEnabled(mContext)) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+
+ return getAmbientConfig().alwaysOnEnabled(mUserId)
+ ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
+ }
+
+ @Override
+ protected boolean canHandleClicks() {
+ return getAmbientConfig().alwaysOnEnabled(mUserId);
}
@Override
package com.android.settings.gestures;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.when;
import android.content.Context;
@Test
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(false);
final int availabilityStatus = mController.getAvailabilityStatus();
@Test
public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
final int availabilityStatus = mController.getAvailabilityStatus();
}
@Test
+ public void getAvailabilityStatus_gestureSupported_DISABLED_DEPENDENT_SETTING() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
+ when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
+ final int availabilityStatus = mController.getAvailabilityStatus();
+
+ assertThat(availabilityStatus).isEqualTo(DISABLED_DEPENDENT_SETTING);
+ }
+
+ @Test
+ public void canHandleClicks_onlyWhenAlwaysOn() {
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
+ assertThat(mController.canHandleClicks()).isEqualTo(false);
+
+ reset(mAmbientDisplayConfiguration);
+ when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
+ assertThat(mController.canHandleClicks()).isEqualTo(true);
+ }
+
+ @Test
public void isSliceableCorrectKey_returnsTrue() {
final WakeScreenGesturePreferenceController controller =
new WakeScreenGesturePreferenceController(mContext, "gesture_wake_screen");