Merge "Fix double tap power key to launch camera locks phone" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-06-03 13:20:50 +00:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 5 deletions

View File

@@ -520,6 +520,14 @@ public class GestureLauncherService extends SystemService {
return intercept && isUserSetupComplete(); return intercept && isUserSetupComplete();
} }
public boolean isCameraDoubleTapPowerEnabled() {
return mCameraDoubleTapPowerEnabled;
}
public boolean isEmergencyGestureEnabled() {
return mEmergencyGestureEnabled;
}
/** /**
* @return true if camera was launched, false otherwise. * @return true if camera was launched, false otherwise.
*/ */

View File

@@ -596,6 +596,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private KeyCombinationManager mKeyCombinationManager; private KeyCombinationManager mKeyCombinationManager;
private SingleKeyGestureDetector mSingleKeyGestureDetector; private SingleKeyGestureDetector mSingleKeyGestureDetector;
private GestureLauncherService mGestureLauncherService;
private boolean mLockNowPending = false; private boolean mLockNowPending = false;
@@ -917,6 +918,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
private void powerPress(long eventTime, int count, boolean beganFromNonInteractive) { private void powerPress(long eventTime, int count, boolean beganFromNonInteractive) {
mCameraGestureTriggered = false;
if (mDefaultDisplayPolicy.isScreenOnEarly() && !mDefaultDisplayPolicy.isScreenOnFully()) { if (mDefaultDisplayPolicy.isScreenOnEarly() && !mDefaultDisplayPolicy.isScreenOnFully()) {
Slog.i(TAG, "Suppressed redundant power key press while " Slog.i(TAG, "Suppressed redundant power key press while "
+ "already in the process of turning the screen on."); + "already in the process of turning the screen on.");
@@ -1066,12 +1068,24 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
private int getMaxMultiPressPowerCount() { private int getMaxMultiPressPowerCount() {
// GestureLauncherService could handle power multi tap gesture.
if (mGestureLauncherService != null
&& mGestureLauncherService.isEmergencyGestureEnabled()) {
return 5; // EMERGENCY_GESTURE_POWER_TAP_COUNT_THRESHOLD
}
if (mTriplePressOnPowerBehavior != MULTI_PRESS_POWER_NOTHING) { if (mTriplePressOnPowerBehavior != MULTI_PRESS_POWER_NOTHING) {
return 3; return 3;
} }
if (mDoublePressOnPowerBehavior != MULTI_PRESS_POWER_NOTHING) { if (mDoublePressOnPowerBehavior != MULTI_PRESS_POWER_NOTHING) {
return 2; return 2;
} }
if (mGestureLauncherService != null
&& mGestureLauncherService.isCameraDoubleTapPowerEnabled()) {
return 2; // CAMERA_POWER_TAP_COUNT_THRESHOLD
}
return 1; return 1;
} }
@@ -3825,15 +3839,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// The camera gesture will be detected by GestureLauncherService. // The camera gesture will be detected by GestureLauncherService.
private boolean handleCameraGesture(KeyEvent event, boolean interactive) { private boolean handleCameraGesture(KeyEvent event, boolean interactive) {
// camera gesture. // camera gesture.
GestureLauncherService gestureService = LocalServices.getService( if (mGestureLauncherService == null) {
GestureLauncherService.class);
if (gestureService == null) {
return false; return false;
} }
final MutableBoolean outLaunched = new MutableBoolean(false); final MutableBoolean outLaunched = new MutableBoolean(false);
final boolean gesturedServiceIntercepted = gestureService.interceptPowerKeyDown(event, final boolean gesturedServiceIntercepted = mGestureLauncherService.interceptPowerKeyDown(
interactive, outLaunched); event, interactive, outLaunched);
if (outLaunched.value) { if (outLaunched.value) {
mCameraGestureTriggered = true; mCameraGestureTriggered = true;
} }
@@ -4689,6 +4701,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
mAutofillManagerInternal = LocalServices.getService(AutofillManagerInternal.class); mAutofillManagerInternal = LocalServices.getService(AutofillManagerInternal.class);
mGestureLauncherService = LocalServices.getService(GestureLauncherService.class);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */