Make WakeScreen conditionally avaialable
Also moving the setting closer to 'Always On' Fixes: 124389844 Test: manual Test: make RunSettingsRoboTests ROBOTEST_FILTER=WakeScreenGesturePreferenceController Change-Id: Ic19e01bf4259608dc0430507fbb3ce5ebf6fa456
This commit is contained in:
@@ -59,6 +59,12 @@
|
|||||||
android:summary="@string/doze_always_on_summary"
|
android:summary="@string/doze_always_on_summary"
|
||||||
settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController" />
|
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
|
<Preference
|
||||||
android:key="ambient_display_tap"
|
android:key="ambient_display_tap"
|
||||||
android:title="@string/ambient_display_tap_screen_title"
|
android:title="@string/ambient_display_tap_screen_title"
|
||||||
@@ -77,12 +83,6 @@
|
|||||||
android:fragment="com.android.settings.gestures.PickupGestureSettings"
|
android:fragment="com.android.settings.gestures.PickupGestureSettings"
|
||||||
settings:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
|
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
|
<SwitchPreference
|
||||||
android:key="ambient_display_notification"
|
android:key="ambient_display_notification"
|
||||||
android:title="@string/doze_title"
|
android:title="@string/doze_title"
|
||||||
|
@@ -53,7 +53,18 @@ public class WakeScreenGesturePreferenceController extends GesturePreferenceCont
|
|||||||
|| !mFeatureProvider.isSupported(mContext)) {
|
|| !mFeatureProvider.isSupported(mContext)) {
|
||||||
return UNSUPPORTED_ON_DEVICE;
|
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
|
@Override
|
||||||
|
@@ -17,12 +17,14 @@
|
|||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
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.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.reset;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -77,6 +79,7 @@ public class WakeScreenGesturePreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
|
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
|
||||||
|
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
|
||||||
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(false);
|
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(false);
|
||||||
final int availabilityStatus = mController.getAvailabilityStatus();
|
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||||
|
|
||||||
@@ -85,12 +88,32 @@ public class WakeScreenGesturePreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
|
public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
|
||||||
|
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
|
||||||
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
|
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
|
||||||
final int availabilityStatus = mController.getAvailabilityStatus();
|
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||||
|
|
||||||
assertThat(availabilityStatus).isEqualTo(AVAILABLE);
|
assertThat(availabilityStatus).isEqualTo(AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
public void isSliceableCorrectKey_returnsTrue() {
|
public void isSliceableCorrectKey_returnsTrue() {
|
||||||
final WakeScreenGesturePreferenceController controller =
|
final WakeScreenGesturePreferenceController controller =
|
||||||
|
Reference in New Issue
Block a user