From 18f18ae078ee97bbdfc9da39d4a19866dceb6a3e Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Thu, 10 Sep 2015 15:48:21 -0700 Subject: Allow camera launch also when device is interactive Bug: 23967648 Change-Id: If91df75e6325b3969dc2351a70af0c160d3eab04 --- .../java/com/android/server/GestureLauncherService.java | 13 ++++++++++--- services/core/java/com/android/server/VibratorService.java | 4 +++- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'services') diff --git a/services/core/java/com/android/server/GestureLauncherService.java b/services/core/java/com/android/server/GestureLauncherService.java index 69f0cef..bd7d4b2 100644 --- a/services/core/java/com/android/server/GestureLauncherService.java +++ b/services/core/java/com/android/server/GestureLauncherService.java @@ -101,8 +101,8 @@ public class GestureLauncherService extends SystemService { * Whether camera double tap power button gesture is currently enabled; */ private boolean mCameraDoubleTapPowerEnabled; - private long mLastPowerDownWhileNonInteractive = 0; - + private long mLastPowerDownWhileNonInteractive; + private long mLastPowerDownWhileInteractive; public GestureLauncherService(Context context) { super(context); @@ -251,23 +251,30 @@ public class GestureLauncherService extends SystemService { public boolean interceptPowerKeyDown(KeyEvent event, boolean interactive) { boolean launched = false; + boolean intercept = false; synchronized (this) { if (!mCameraDoubleTapPowerEnabled) { mLastPowerDownWhileNonInteractive = 0; + mLastPowerDownWhileInteractive = 0; return false; } if (event.getEventTime() - mLastPowerDownWhileNonInteractive < CAMERA_POWER_DOUBLE_TAP_TIME_MS) { launched = true; + intercept = true; + } else if (event.getEventTime() - mLastPowerDownWhileInteractive + < CAMERA_POWER_DOUBLE_TAP_TIME_MS) { + launched = true; } mLastPowerDownWhileNonInteractive = interactive ? 0 : event.getEventTime(); + mLastPowerDownWhileInteractive = interactive ? event.getEventTime() : 0; } if (launched) { Slog.i(TAG, "Power button double tap gesture detected, launching camera."); launched = handleCameraLaunchGesture(false /* useWakelock */, MetricsLogger.ACTION_DOUBLE_TAP_POWER_CAMERA_GESTURE); } - return launched; + return intercept && launched; } /** diff --git a/services/core/java/com/android/server/VibratorService.java b/services/core/java/com/android/server/VibratorService.java index 30f4dce..c228422 100644 --- a/services/core/java/com/android/server/VibratorService.java +++ b/services/core/java/com/android/server/VibratorService.java @@ -59,6 +59,7 @@ public class VibratorService extends IVibratorService.Stub implements InputManager.InputDeviceListener { private static final String TAG = "VibratorService"; private static final boolean DEBUG = false; + private static final String SYSTEM_UI_PACKAGE = "com.android.systemui"; private final LinkedList mVibrations; private final LinkedList mPreviousVibrations; @@ -147,7 +148,8 @@ public class VibratorService extends IVibratorService.Stub } public boolean isSystemHapticFeedback() { - return (mUid == Process.SYSTEM_UID || mUid == 0) && mRepeat < 0; + return (mUid == Process.SYSTEM_UID || mUid == 0 || SYSTEM_UI_PACKAGE.equals(mOpPkg)) + && mRepeat < 0; } } -- cgit v1.1