Loading core/res/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -3303,6 +3303,10 @@ is non-interactive. --> <bool name="config_cameraDoubleTapPowerGestureEnabled">true</bool> <!-- Allow the gesture to quick tap the power button multiple times to start the emergency sos experience while the device is non-interactive. --> <bool name="config_emergencyGestureEnabled">true</bool> <!-- Allow the gesture power + volume up to change the ringer mode while the device is interactive. --> <bool name="config_volumeHushGestureEnabled">true</bool> Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2823,6 +2823,7 @@ <java-symbol type="bool" name="config_cameraDoubleTapPowerGestureEnabled" /> <java-symbol type="integer" name="config_cameraLiftTriggerSensorType" /> <java-symbol type="string" name="config_cameraLiftTriggerSensorStringType" /> <java-symbol type="bool" name="config_emergencyGestureEnabled" /> <java-symbol type="bool" name="config_volumeHushGestureEnabled" /> <java-symbol type="drawable" name="platlogo_m" /> Loading services/core/java/com/android/server/GestureLauncherService.java +20 −8 Original line number Diff line number Diff line Loading @@ -257,7 +257,7 @@ public class GestureLauncherService extends SystemService { @VisibleForTesting void updateEmergencyGestureEnabled() { boolean enabled = isEmergencyGestureEnabled(mContext, mUserId); boolean enabled = isEmergencyGestureSettingEnabled(mContext, mUserId); synchronized (this) { mEmergencyGestureEnabled = enabled; } Loading Loading @@ -390,38 +390,50 @@ public class GestureLauncherService extends SystemService { /** * Whether to enable emergency gesture. */ public static boolean isEmergencyGestureEnabled(Context context, int userId) { return Settings.Secure.getIntForUser(context.getContentResolver(), @VisibleForTesting static boolean isEmergencyGestureSettingEnabled(Context context, int userId) { return isEmergencyGestureEnabled(context.getResources()) && Settings.Secure.getIntForUser(context.getContentResolver(), Settings.Secure.EMERGENCY_GESTURE_ENABLED, 0, userId) != 0; } /** * Whether to enable the camera launch gesture. */ public static boolean isCameraLaunchEnabled(Resources resources) { private static boolean isCameraLaunchEnabled(Resources resources) { boolean configSet = resources.getInteger( com.android.internal.R.integer.config_cameraLaunchGestureSensorType) != -1; return configSet && !SystemProperties.getBoolean("gesture.disable_camera_launch", false); } public static boolean isCameraDoubleTapPowerEnabled(Resources resources) { @VisibleForTesting static boolean isCameraDoubleTapPowerEnabled(Resources resources) { return resources.getBoolean( com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled); } public static boolean isCameraLiftTriggerEnabled(Resources resources) { private static boolean isCameraLiftTriggerEnabled(Resources resources) { boolean configSet = resources.getInteger( com.android.internal.R.integer.config_cameraLiftTriggerSensorType) != -1; return configSet; } /** * Whether or not the emergency gesture feature is enabled by platform */ private static boolean isEmergencyGestureEnabled(Resources resources) { return resources.getBoolean(com.android.internal.R.bool.config_emergencyGestureEnabled); } /** * Whether GestureLauncherService should be enabled according to system properties. */ public static boolean isGestureLauncherEnabled(Resources resources) { return isCameraLaunchEnabled(resources) || isCameraDoubleTapPowerEnabled(resources) || isCameraLiftTriggerEnabled(resources); return isCameraLaunchEnabled(resources) || isCameraDoubleTapPowerEnabled(resources) || isCameraLiftTriggerEnabled(resources) || isEmergencyGestureEnabled(resources); } /** Loading services/tests/servicestests/src/com/android/server/GestureLauncherServiceTest.java +23 −4 Original line number Diff line number Diff line Loading @@ -163,16 +163,26 @@ public class GestureLauncherServiceTest { } @Test public void testIsEmergencyGestureEnabled_settingDisabled() { public void testIsEmergencyGestureSettingEnabled_settingDisabled() { withEmergencyGestureEnabledConfigValue(true); withEmergencyGestureEnabledSettingValue(false); assertFalse(mGestureLauncherService.isEmergencyGestureEnabled( assertFalse(mGestureLauncherService.isEmergencyGestureSettingEnabled( mContext, FAKE_USER_ID)); } @Test public void testIsEmergencyGestureEnabled_settingEnabled() { public void testIsEmergencyGestureSettingEnabled_settingEnabled() { withEmergencyGestureEnabledConfigValue(true); withEmergencyGestureEnabledSettingValue(true); assertTrue(mGestureLauncherService.isEmergencyGestureEnabled( assertTrue(mGestureLauncherService.isEmergencyGestureSettingEnabled( mContext, FAKE_USER_ID)); } @Test public void testIsEmergencyGestureSettingEnabled_supportDisabled() { withEmergencyGestureEnabledConfigValue(false); withEmergencyGestureEnabledSettingValue(true); assertFalse(mGestureLauncherService.isEmergencyGestureSettingEnabled( mContext, FAKE_USER_ID)); } Loading Loading @@ -438,6 +448,7 @@ public class GestureLauncherServiceTest { testInterceptPowerKeyDown_fiveInboundPresses_cameraAndEmergencyEnabled_bothLaunch() { withCameraDoubleTapPowerEnableConfigValue(true); withCameraDoubleTapPowerDisableSettingValue(0); withEmergencyGestureEnabledConfigValue(true); withEmergencyGestureEnabledSettingValue(true); mGestureLauncherService.updateCameraDoubleTapPowerEnabled(); mGestureLauncherService.updateEmergencyGestureEnabled(); Loading Loading @@ -527,6 +538,7 @@ public class GestureLauncherServiceTest { @Test public void testInterceptPowerKeyDown_fiveInboundPresses_emergencyGestureEnabled_launchesFlow() { withEmergencyGestureEnabledConfigValue(true); withEmergencyGestureEnabledSettingValue(true); mGestureLauncherService.updateEmergencyGestureEnabled(); withUserSetupCompleteValue(true); Loading Loading @@ -580,6 +592,7 @@ public class GestureLauncherServiceTest { @Test public void testInterceptPowerKeyDown_tenInboundPresses_emergencyGestureEnabled_keyIntercepted() { withEmergencyGestureEnabledConfigValue(true); withEmergencyGestureEnabledSettingValue(true); mGestureLauncherService.updateEmergencyGestureEnabled(); withUserSetupCompleteValue(true); Loading Loading @@ -1146,6 +1159,12 @@ public class GestureLauncherServiceTest { .thenReturn(enableConfigValue); } private void withEmergencyGestureEnabledConfigValue(boolean enableConfigValue) { when(mResources.getBoolean( com.android.internal.R.bool.config_emergencyGestureEnabled)) .thenReturn(enableConfigValue); } private void withCameraDoubleTapPowerDisableSettingValue(int disableSettingValue) { Settings.Secure.putIntForUser( mContentResolver, Loading Loading
core/res/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -3303,6 +3303,10 @@ is non-interactive. --> <bool name="config_cameraDoubleTapPowerGestureEnabled">true</bool> <!-- Allow the gesture to quick tap the power button multiple times to start the emergency sos experience while the device is non-interactive. --> <bool name="config_emergencyGestureEnabled">true</bool> <!-- Allow the gesture power + volume up to change the ringer mode while the device is interactive. --> <bool name="config_volumeHushGestureEnabled">true</bool> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2823,6 +2823,7 @@ <java-symbol type="bool" name="config_cameraDoubleTapPowerGestureEnabled" /> <java-symbol type="integer" name="config_cameraLiftTriggerSensorType" /> <java-symbol type="string" name="config_cameraLiftTriggerSensorStringType" /> <java-symbol type="bool" name="config_emergencyGestureEnabled" /> <java-symbol type="bool" name="config_volumeHushGestureEnabled" /> <java-symbol type="drawable" name="platlogo_m" /> Loading
services/core/java/com/android/server/GestureLauncherService.java +20 −8 Original line number Diff line number Diff line Loading @@ -257,7 +257,7 @@ public class GestureLauncherService extends SystemService { @VisibleForTesting void updateEmergencyGestureEnabled() { boolean enabled = isEmergencyGestureEnabled(mContext, mUserId); boolean enabled = isEmergencyGestureSettingEnabled(mContext, mUserId); synchronized (this) { mEmergencyGestureEnabled = enabled; } Loading Loading @@ -390,38 +390,50 @@ public class GestureLauncherService extends SystemService { /** * Whether to enable emergency gesture. */ public static boolean isEmergencyGestureEnabled(Context context, int userId) { return Settings.Secure.getIntForUser(context.getContentResolver(), @VisibleForTesting static boolean isEmergencyGestureSettingEnabled(Context context, int userId) { return isEmergencyGestureEnabled(context.getResources()) && Settings.Secure.getIntForUser(context.getContentResolver(), Settings.Secure.EMERGENCY_GESTURE_ENABLED, 0, userId) != 0; } /** * Whether to enable the camera launch gesture. */ public static boolean isCameraLaunchEnabled(Resources resources) { private static boolean isCameraLaunchEnabled(Resources resources) { boolean configSet = resources.getInteger( com.android.internal.R.integer.config_cameraLaunchGestureSensorType) != -1; return configSet && !SystemProperties.getBoolean("gesture.disable_camera_launch", false); } public static boolean isCameraDoubleTapPowerEnabled(Resources resources) { @VisibleForTesting static boolean isCameraDoubleTapPowerEnabled(Resources resources) { return resources.getBoolean( com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled); } public static boolean isCameraLiftTriggerEnabled(Resources resources) { private static boolean isCameraLiftTriggerEnabled(Resources resources) { boolean configSet = resources.getInteger( com.android.internal.R.integer.config_cameraLiftTriggerSensorType) != -1; return configSet; } /** * Whether or not the emergency gesture feature is enabled by platform */ private static boolean isEmergencyGestureEnabled(Resources resources) { return resources.getBoolean(com.android.internal.R.bool.config_emergencyGestureEnabled); } /** * Whether GestureLauncherService should be enabled according to system properties. */ public static boolean isGestureLauncherEnabled(Resources resources) { return isCameraLaunchEnabled(resources) || isCameraDoubleTapPowerEnabled(resources) || isCameraLiftTriggerEnabled(resources); return isCameraLaunchEnabled(resources) || isCameraDoubleTapPowerEnabled(resources) || isCameraLiftTriggerEnabled(resources) || isEmergencyGestureEnabled(resources); } /** Loading
services/tests/servicestests/src/com/android/server/GestureLauncherServiceTest.java +23 −4 Original line number Diff line number Diff line Loading @@ -163,16 +163,26 @@ public class GestureLauncherServiceTest { } @Test public void testIsEmergencyGestureEnabled_settingDisabled() { public void testIsEmergencyGestureSettingEnabled_settingDisabled() { withEmergencyGestureEnabledConfigValue(true); withEmergencyGestureEnabledSettingValue(false); assertFalse(mGestureLauncherService.isEmergencyGestureEnabled( assertFalse(mGestureLauncherService.isEmergencyGestureSettingEnabled( mContext, FAKE_USER_ID)); } @Test public void testIsEmergencyGestureEnabled_settingEnabled() { public void testIsEmergencyGestureSettingEnabled_settingEnabled() { withEmergencyGestureEnabledConfigValue(true); withEmergencyGestureEnabledSettingValue(true); assertTrue(mGestureLauncherService.isEmergencyGestureEnabled( assertTrue(mGestureLauncherService.isEmergencyGestureSettingEnabled( mContext, FAKE_USER_ID)); } @Test public void testIsEmergencyGestureSettingEnabled_supportDisabled() { withEmergencyGestureEnabledConfigValue(false); withEmergencyGestureEnabledSettingValue(true); assertFalse(mGestureLauncherService.isEmergencyGestureSettingEnabled( mContext, FAKE_USER_ID)); } Loading Loading @@ -438,6 +448,7 @@ public class GestureLauncherServiceTest { testInterceptPowerKeyDown_fiveInboundPresses_cameraAndEmergencyEnabled_bothLaunch() { withCameraDoubleTapPowerEnableConfigValue(true); withCameraDoubleTapPowerDisableSettingValue(0); withEmergencyGestureEnabledConfigValue(true); withEmergencyGestureEnabledSettingValue(true); mGestureLauncherService.updateCameraDoubleTapPowerEnabled(); mGestureLauncherService.updateEmergencyGestureEnabled(); Loading Loading @@ -527,6 +538,7 @@ public class GestureLauncherServiceTest { @Test public void testInterceptPowerKeyDown_fiveInboundPresses_emergencyGestureEnabled_launchesFlow() { withEmergencyGestureEnabledConfigValue(true); withEmergencyGestureEnabledSettingValue(true); mGestureLauncherService.updateEmergencyGestureEnabled(); withUserSetupCompleteValue(true); Loading Loading @@ -580,6 +592,7 @@ public class GestureLauncherServiceTest { @Test public void testInterceptPowerKeyDown_tenInboundPresses_emergencyGestureEnabled_keyIntercepted() { withEmergencyGestureEnabledConfigValue(true); withEmergencyGestureEnabledSettingValue(true); mGestureLauncherService.updateEmergencyGestureEnabled(); withUserSetupCompleteValue(true); Loading Loading @@ -1146,6 +1159,12 @@ public class GestureLauncherServiceTest { .thenReturn(enableConfigValue); } private void withEmergencyGestureEnabledConfigValue(boolean enableConfigValue) { when(mResources.getBoolean( com.android.internal.R.bool.config_emergencyGestureEnabled)) .thenReturn(enableConfigValue); } private void withCameraDoubleTapPowerDisableSettingValue(int disableSettingValue) { Settings.Secure.putIntForUser( mContentResolver, Loading