Fix availability status for AOD gestures
Double tap screen to wake and lift to check phone are dependent on AOD - and should return DISABLED DEPENDENT SETTING when AOD is turned on. Test: robotests Change-Id: Ib246070ee853185459628b2584ddbae72e15a2f8
This commit is contained in:
@@ -22,6 +22,8 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
@@ -74,7 +76,18 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
|
|||||||
if (mAmbientConfig == null) {
|
if (mAmbientConfig == null) {
|
||||||
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
||||||
}
|
}
|
||||||
return mAmbientConfig.pulseOnDoubleTapAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
|
||||||
|
// No hardware support for Double Tap
|
||||||
|
if (!mAmbientConfig.doubleTapSensorAvailable()) {
|
||||||
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can't change Double Tap when AOD is enabled.
|
||||||
|
if (!mAmbientConfig.ambientDisplayAvailable()) {
|
||||||
|
return DISABLED_DEPENDENT_SETTING;
|
||||||
|
}
|
||||||
|
|
||||||
|
return AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -25,6 +25,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -68,7 +69,18 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
|
|||||||
if (mAmbientConfig == null) {
|
if (mAmbientConfig == null) {
|
||||||
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
||||||
}
|
}
|
||||||
return mAmbientConfig.pulseOnPickupAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
|
||||||
|
// No hardware support for Pickup Gesture
|
||||||
|
if (!mAmbientConfig.dozePulsePickupSensorAvailable()) {
|
||||||
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can't change Pickup Gesture when AOD is enabled.
|
||||||
|
if (!mAmbientConfig.ambientDisplayAvailable()) {
|
||||||
|
return DISABLED_DEPENDENT_SETTING;
|
||||||
|
}
|
||||||
|
|
||||||
|
return AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
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.DISABLED_DEPENDENT_SETTING;
|
||||||
|
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.Matchers.anyInt;
|
import static org.mockito.Matchers.anyInt;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -60,20 +64,6 @@ public class DoubleTapScreenPreferenceControllerTest {
|
|||||||
mController.setConfig(mAmbientDisplayConfiguration);
|
mController.setConfig(mAmbientDisplayConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isAvailable_configIsTrue_shouldReturnTrue() {
|
|
||||||
when(mAmbientDisplayConfiguration.pulseOnDoubleTapAvailable()).thenReturn(true);
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isAvailable_configIsFalse_shouldReturnFalse() {
|
|
||||||
when(mAmbientDisplayConfiguration.pulseOnDoubleTapAvailable()).thenReturn(false);
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChecked_configIsSet_shouldReturnTrue() {
|
public void testIsChecked_configIsSet_shouldReturnTrue() {
|
||||||
// Set the setting to be enabled.
|
// Set the setting to be enabled.
|
||||||
@@ -162,4 +152,31 @@ public class DoubleTapScreenPreferenceControllerTest {
|
|||||||
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
|
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
|
||||||
assertThat(mController.canHandleClicks()).isTrue();
|
assertThat(mController.canHandleClicks()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_aodNotSupported_UNSUPPORTED_ON_DEVICE() {
|
||||||
|
when(mAmbientDisplayConfiguration.doubleTapSensorAvailable()).thenReturn(false);
|
||||||
|
when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(false);
|
||||||
|
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||||
|
|
||||||
|
assertThat(availabilityStatus).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_aodOn_DISABLED_DEPENDENT_SETTING() {
|
||||||
|
when(mAmbientDisplayConfiguration.doubleTapSensorAvailable()).thenReturn(true);
|
||||||
|
when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(false);
|
||||||
|
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||||
|
|
||||||
|
assertThat(availabilityStatus).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_aodSupported_aodOff_AVAILABLE() {
|
||||||
|
when(mAmbientDisplayConfiguration.doubleTapSensorAvailable()).thenReturn(true);
|
||||||
|
when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(true);
|
||||||
|
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||||
|
|
||||||
|
assertThat(availabilityStatus).isEqualTo(AVAILABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
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.DISABLED_DEPENDENT_SETTING;
|
||||||
|
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.Matchers.anyInt;
|
import static org.mockito.Matchers.anyInt;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
@@ -61,20 +65,6 @@ public class PickupGesturePreferenceControllerTest {
|
|||||||
mController.setConfig(mAmbientDisplayConfiguration);
|
mController.setConfig(mAmbientDisplayConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isAvailable_configIsTrue_shouldReturnTrue() {
|
|
||||||
when(mAmbientDisplayConfiguration.pulseOnPickupAvailable()).thenReturn(true);
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isAvailable_configIsFalse_shouldReturnFalse() {
|
|
||||||
when(mAmbientDisplayConfiguration.pulseOnPickupAvailable()).thenReturn(false);
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsChecked_configIsSet_shouldReturnTrue() {
|
public void testIsChecked_configIsSet_shouldReturnTrue() {
|
||||||
// Set the setting to be enabled.
|
// Set the setting to be enabled.
|
||||||
@@ -153,4 +143,31 @@ public class PickupGesturePreferenceControllerTest {
|
|||||||
assertThat(PickupGesturePreferenceController.isSuggestionComplete(mContext, prefs))
|
assertThat(PickupGesturePreferenceController.isSuggestionComplete(mContext, prefs))
|
||||||
.isTrue();
|
.isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_aodNotSupported_UNSUPPORTED_ON_DEVICE() {
|
||||||
|
when(mAmbientDisplayConfiguration.dozePulsePickupSensorAvailable()).thenReturn(false);
|
||||||
|
when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(false);
|
||||||
|
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||||
|
|
||||||
|
assertThat(availabilityStatus).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_aodOn_DISABLED_DEPENDENT_SETTING() {
|
||||||
|
when(mAmbientDisplayConfiguration.dozePulsePickupSensorAvailable()).thenReturn(true);
|
||||||
|
when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(false);
|
||||||
|
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||||
|
|
||||||
|
assertThat(availabilityStatus).isEqualTo(DISABLED_DEPENDENT_SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_aodSupported_aodOff_AVAILABLE() {
|
||||||
|
when(mAmbientDisplayConfiguration.dozePulsePickupSensorAvailable()).thenReturn(true);
|
||||||
|
when(mAmbientDisplayConfiguration.ambientDisplayAvailable()).thenReturn(true);
|
||||||
|
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||||
|
|
||||||
|
assertThat(availabilityStatus).isEqualTo(AVAILABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user