Loading core/res/res/values/config.xml +0 −6 Original line number Diff line number Diff line Loading @@ -4948,12 +4948,6 @@ button. --> <integer name="config_mashPressVibrateTimeOnPowerButton">0</integer> <!-- Control the behavior when the user presses the power button 5 times. 0 - Nothing 1 - Launch panic button gesture --> <integer name="config_mashPressOnPowerBehavior">0</integer> <!-- Whether or not to enable the binder heavy hitter watcher by default --> <bool name="config_defaultBinderHeavyHitterWatcherEnabled">false</bool> Loading core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -4617,4 +4617,6 @@ <java-symbol type="array" name="config_roundedCornerBottomRadiusAdjustmentArray" /> <java-symbol type="bool" name="config_secondaryBuiltInDisplayIsRound" /> <java-symbol type="array" name="config_builtInDisplayIsRoundArray" /> <java-symbol type="integer" name="config_mashPressVibrateTimeOnPowerButton" /> </resources> services/core/java/com/android/server/GestureLauncherService.java +62 −0 Original line number Diff line number Diff line Loading @@ -19,10 +19,12 @@ package com.android.server; import android.app.ActivityManager; import android.app.StatusBarManager; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.database.ContentObserver; import android.hardware.Sensor; Loading @@ -38,6 +40,8 @@ import android.os.SystemClock; import android.os.SystemProperties; import android.os.Trace; import android.os.UserHandle; import android.os.VibrationEffect; import android.os.Vibrator; import android.provider.Settings; import android.util.MutableBoolean; import android.util.Slog; Loading Loading @@ -88,6 +92,19 @@ public class GestureLauncherService extends SystemService { */ private static final int CAMERA_POWER_TAP_COUNT_THRESHOLD = 2; /** Action for starting emergency alerts on Wear OS. */ private static final String WEAR_LAUNCH_EMERGENCY_ACTION = "com.android.systemui.action.LAUNCH_EMERGENCY"; /** Action for starting emergency alerts in retail mode on Wear OS. */ private static final String WEAR_LAUNCH_EMERGENCY_RETAIL_ACTION = "com.android.systemui.action.LAUNCH_EMERGENCY_RETAIL"; /** * Boolean extra for distinguishing intents coming from power button gesture. */ private static final String EXTRA_LAUNCH_EMERGENCY_VIA_GESTURE = "launch_emergency_via_gesture"; /** The listener that receives the gesture event. */ private final GestureEventListener mGestureListener = new GestureEventListener(); private final CameraLiftTriggerEventListener mCameraLiftTriggerListener = Loading Loading @@ -152,6 +169,7 @@ public class GestureLauncherService extends SystemService { private final UiEventLogger mUiEventLogger; private boolean mHasFeatureWatch; private long mVibrateMilliSecondsForPanicGesture; @VisibleForTesting public enum GestureLauncherEvent implements UiEventLogger.UiEventEnum { Loading Loading @@ -220,6 +238,13 @@ public class GestureLauncherService extends SystemService { mHasFeatureWatch = mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH); mVibrateMilliSecondsForPanicGesture = resources.getInteger( com.android .internal .R .integer .config_mashPressVibrateTimeOnPowerButton); } } Loading Loading @@ -584,6 +609,12 @@ public class GestureLauncherService extends SystemService { "userSetupComplete = %s, performing emergency gesture.", userSetupComplete)); } if (mHasFeatureWatch) { onEmergencyGestureDetectedOnWatch(); return true; } StatusBarManagerInternal service = LocalServices.getService( StatusBarManagerInternal.class); service.onEmergencyActionLaunchGestureDetected(); Loading @@ -593,6 +624,37 @@ public class GestureLauncherService extends SystemService { } } private void onEmergencyGestureDetectedOnWatch() { Intent emergencyIntent = new Intent( isInRetailMode() ? WEAR_LAUNCH_EMERGENCY_RETAIL_ACTION : WEAR_LAUNCH_EMERGENCY_ACTION); PackageManager pm = mContext.getPackageManager(); ResolveInfo resolveInfo = pm.resolveActivity(emergencyIntent, /*flags=*/0); if (resolveInfo == null) { Slog.w(TAG, "Couldn't find an app to process the emergency intent " + emergencyIntent.getAction()); return; } Vibrator vibrator = mContext.getSystemService(Vibrator.class); vibrator.vibrate(VibrationEffect.createOneShot(mVibrateMilliSecondsForPanicGesture, VibrationEffect.DEFAULT_AMPLITUDE)); emergencyIntent.setComponent( new ComponentName( resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name)); emergencyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emergencyIntent.putExtra(EXTRA_LAUNCH_EMERGENCY_VIA_GESTURE, true); mContext.startActivityAsUser(emergencyIntent, new UserHandle(mUserId)); } private boolean isInRetailMode() { return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.DEVICE_DEMO_MODE, 0) == 1; } private boolean isUserSetupComplete() { return Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0; Loading Loading
core/res/res/values/config.xml +0 −6 Original line number Diff line number Diff line Loading @@ -4948,12 +4948,6 @@ button. --> <integer name="config_mashPressVibrateTimeOnPowerButton">0</integer> <!-- Control the behavior when the user presses the power button 5 times. 0 - Nothing 1 - Launch panic button gesture --> <integer name="config_mashPressOnPowerBehavior">0</integer> <!-- Whether or not to enable the binder heavy hitter watcher by default --> <bool name="config_defaultBinderHeavyHitterWatcherEnabled">false</bool> Loading
core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -4617,4 +4617,6 @@ <java-symbol type="array" name="config_roundedCornerBottomRadiusAdjustmentArray" /> <java-symbol type="bool" name="config_secondaryBuiltInDisplayIsRound" /> <java-symbol type="array" name="config_builtInDisplayIsRoundArray" /> <java-symbol type="integer" name="config_mashPressVibrateTimeOnPowerButton" /> </resources>
services/core/java/com/android/server/GestureLauncherService.java +62 −0 Original line number Diff line number Diff line Loading @@ -19,10 +19,12 @@ package com.android.server; import android.app.ActivityManager; import android.app.StatusBarManager; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.database.ContentObserver; import android.hardware.Sensor; Loading @@ -38,6 +40,8 @@ import android.os.SystemClock; import android.os.SystemProperties; import android.os.Trace; import android.os.UserHandle; import android.os.VibrationEffect; import android.os.Vibrator; import android.provider.Settings; import android.util.MutableBoolean; import android.util.Slog; Loading Loading @@ -88,6 +92,19 @@ public class GestureLauncherService extends SystemService { */ private static final int CAMERA_POWER_TAP_COUNT_THRESHOLD = 2; /** Action for starting emergency alerts on Wear OS. */ private static final String WEAR_LAUNCH_EMERGENCY_ACTION = "com.android.systemui.action.LAUNCH_EMERGENCY"; /** Action for starting emergency alerts in retail mode on Wear OS. */ private static final String WEAR_LAUNCH_EMERGENCY_RETAIL_ACTION = "com.android.systemui.action.LAUNCH_EMERGENCY_RETAIL"; /** * Boolean extra for distinguishing intents coming from power button gesture. */ private static final String EXTRA_LAUNCH_EMERGENCY_VIA_GESTURE = "launch_emergency_via_gesture"; /** The listener that receives the gesture event. */ private final GestureEventListener mGestureListener = new GestureEventListener(); private final CameraLiftTriggerEventListener mCameraLiftTriggerListener = Loading Loading @@ -152,6 +169,7 @@ public class GestureLauncherService extends SystemService { private final UiEventLogger mUiEventLogger; private boolean mHasFeatureWatch; private long mVibrateMilliSecondsForPanicGesture; @VisibleForTesting public enum GestureLauncherEvent implements UiEventLogger.UiEventEnum { Loading Loading @@ -220,6 +238,13 @@ public class GestureLauncherService extends SystemService { mHasFeatureWatch = mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH); mVibrateMilliSecondsForPanicGesture = resources.getInteger( com.android .internal .R .integer .config_mashPressVibrateTimeOnPowerButton); } } Loading Loading @@ -584,6 +609,12 @@ public class GestureLauncherService extends SystemService { "userSetupComplete = %s, performing emergency gesture.", userSetupComplete)); } if (mHasFeatureWatch) { onEmergencyGestureDetectedOnWatch(); return true; } StatusBarManagerInternal service = LocalServices.getService( StatusBarManagerInternal.class); service.onEmergencyActionLaunchGestureDetected(); Loading @@ -593,6 +624,37 @@ public class GestureLauncherService extends SystemService { } } private void onEmergencyGestureDetectedOnWatch() { Intent emergencyIntent = new Intent( isInRetailMode() ? WEAR_LAUNCH_EMERGENCY_RETAIL_ACTION : WEAR_LAUNCH_EMERGENCY_ACTION); PackageManager pm = mContext.getPackageManager(); ResolveInfo resolveInfo = pm.resolveActivity(emergencyIntent, /*flags=*/0); if (resolveInfo == null) { Slog.w(TAG, "Couldn't find an app to process the emergency intent " + emergencyIntent.getAction()); return; } Vibrator vibrator = mContext.getSystemService(Vibrator.class); vibrator.vibrate(VibrationEffect.createOneShot(mVibrateMilliSecondsForPanicGesture, VibrationEffect.DEFAULT_AMPLITUDE)); emergencyIntent.setComponent( new ComponentName( resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name)); emergencyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emergencyIntent.putExtra(EXTRA_LAUNCH_EMERGENCY_VIA_GESTURE, true); mContext.startActivityAsUser(emergencyIntent, new UserHandle(mUserId)); } private boolean isInRetailMode() { return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.DEVICE_DEMO_MODE, 0) == 1; } private boolean isUserSetupComplete() { return Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0; Loading