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:
Lucas Dupin
2019-02-13 13:08:09 -08:00
parent cd15971f14
commit 862aaed38c
3 changed files with 41 additions and 7 deletions

View File

@@ -59,6 +59,12 @@
android:summary="@string/doze_always_on_summary"
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"
@@ -77,12 +83,6 @@
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"

View File

@@ -53,7 +53,18 @@ public class WakeScreenGesturePreferenceController extends GesturePreferenceCont
|| !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

View File

@@ -17,12 +17,14 @@
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;
@@ -77,6 +79,7 @@ public class WakeScreenGesturePreferenceControllerTest {
@Test
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(false);
final int availabilityStatus = mController.getAvailabilityStatus();
@@ -85,12 +88,32 @@ public class WakeScreenGesturePreferenceControllerTest {
@Test
public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
final int availabilityStatus = mController.getAvailabilityStatus();
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
public void isSliceableCorrectKey_returnsTrue() {
final WakeScreenGesturePreferenceController controller =