Allow camera launch also when device is interactive
Bug: 23967648 Change-Id: If91df75e6325b3969dc2351a70af0c160d3eab04
This commit is contained in:
@@ -154,6 +154,7 @@ public class KeyguardViewMediator extends SystemUI {
|
|||||||
private static final int NOTIFY_STARTED_WAKING_UP = 21;
|
private static final int NOTIFY_STARTED_WAKING_UP = 21;
|
||||||
private static final int NOTIFY_SCREEN_TURNED_ON = 22;
|
private static final int NOTIFY_SCREEN_TURNED_ON = 22;
|
||||||
private static final int NOTIFY_SCREEN_TURNED_OFF = 23;
|
private static final int NOTIFY_SCREEN_TURNED_OFF = 23;
|
||||||
|
private static final int NOTIFY_STARTED_GOING_TO_SLEEP = 24;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default amount of time we stay awake (used for all key input)
|
* The default amount of time we stay awake (used for all key input)
|
||||||
@@ -676,6 +677,7 @@ public class KeyguardViewMediator extends SystemUI {
|
|||||||
playSounds(true);
|
playSounds(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
notifyStartedGoingToSleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onFinishedGoingToSleep(int why) {
|
public void onFinishedGoingToSleep(int why) {
|
||||||
@@ -1092,6 +1094,11 @@ public class KeyguardViewMediator extends SystemUI {
|
|||||||
mHandler.sendEmptyMessage(VERIFY_UNLOCK);
|
mHandler.sendEmptyMessage(VERIFY_UNLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void notifyStartedGoingToSleep() {
|
||||||
|
if (DEBUG) Log.d(TAG, "notifyStartedGoingToSleep");
|
||||||
|
mHandler.sendEmptyMessage(NOTIFY_STARTED_GOING_TO_SLEEP);
|
||||||
|
}
|
||||||
|
|
||||||
private void notifyFinishedGoingToSleep() {
|
private void notifyFinishedGoingToSleep() {
|
||||||
if (DEBUG) Log.d(TAG, "notifyFinishedGoingToSleep");
|
if (DEBUG) Log.d(TAG, "notifyFinishedGoingToSleep");
|
||||||
mHandler.sendEmptyMessage(NOTIFY_FINISHED_GOING_TO_SLEEP);
|
mHandler.sendEmptyMessage(NOTIFY_FINISHED_GOING_TO_SLEEP);
|
||||||
@@ -1203,6 +1210,9 @@ public class KeyguardViewMediator extends SystemUI {
|
|||||||
case VERIFY_UNLOCK:
|
case VERIFY_UNLOCK:
|
||||||
handleVerifyUnlock();
|
handleVerifyUnlock();
|
||||||
break;
|
break;
|
||||||
|
case NOTIFY_STARTED_GOING_TO_SLEEP:
|
||||||
|
handleNotifyStartedGoingToSleep();
|
||||||
|
break;
|
||||||
case NOTIFY_FINISHED_GOING_TO_SLEEP:
|
case NOTIFY_FINISHED_GOING_TO_SLEEP:
|
||||||
handleNotifyFinishedGoingToSleep();
|
handleNotifyFinishedGoingToSleep();
|
||||||
break;
|
break;
|
||||||
@@ -1530,6 +1540,13 @@ public class KeyguardViewMediator extends SystemUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleNotifyStartedGoingToSleep() {
|
||||||
|
synchronized (KeyguardViewMediator.this) {
|
||||||
|
if (DEBUG) Log.d(TAG, "handleNotifyStartedGoingToSleep");
|
||||||
|
mStatusBarKeyguardViewManager.onStartedGoingToSleep();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle message sent by {@link #notifyFinishedGoingToSleep()}
|
* Handle message sent by {@link #notifyFinishedGoingToSleep()}
|
||||||
* @see #NOTIFY_FINISHED_GOING_TO_SLEEP
|
* @see #NOTIFY_FINISHED_GOING_TO_SLEEP
|
||||||
|
|||||||
@@ -488,12 +488,18 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
private boolean mLaunchTransitionFadingAway;
|
private boolean mLaunchTransitionFadingAway;
|
||||||
private ExpandableNotificationRow mDraggedDownRow;
|
private ExpandableNotificationRow mDraggedDownRow;
|
||||||
private boolean mLaunchCameraOnScreenTurningOn;
|
private boolean mLaunchCameraOnScreenTurningOn;
|
||||||
|
private boolean mLaunchCameraOnFinishedGoingToSleep;
|
||||||
private PowerManager.WakeLock mGestureWakeLock;
|
private PowerManager.WakeLock mGestureWakeLock;
|
||||||
private Vibrator mVibrator;
|
private Vibrator mVibrator;
|
||||||
|
|
||||||
// Fingerprint (as computed by getLoggingFingerprint() of the last logged state.
|
// Fingerprint (as computed by getLoggingFingerprint() of the last logged state.
|
||||||
private int mLastLoggedStateFingerprint;
|
private int mLastLoggedStateFingerprint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set, the device has started going to sleep but isn't fully non-interactive yet.
|
||||||
|
*/
|
||||||
|
protected boolean mStartedGoingToSleep;
|
||||||
|
|
||||||
private static final int VISIBLE_LOCATIONS = StackViewState.LOCATION_FIRST_CARD
|
private static final int VISIBLE_LOCATIONS = StackViewState.LOCATION_FIRST_CARD
|
||||||
| StackViewState.LOCATION_MAIN_AREA;
|
| StackViewState.LOCATION_MAIN_AREA;
|
||||||
|
|
||||||
@@ -3908,15 +3914,32 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
disable(mDisabledUnmodified1, mDisabledUnmodified2, true /* animate */);
|
disable(mDisabledUnmodified1, mDisabledUnmodified2, true /* animate */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onStartedGoingToSleep() {
|
||||||
|
mStartedGoingToSleep = true;
|
||||||
|
}
|
||||||
|
|
||||||
public void onFinishedGoingToSleep() {
|
public void onFinishedGoingToSleep() {
|
||||||
mNotificationPanel.onAffordanceLaunchEnded();
|
mNotificationPanel.onAffordanceLaunchEnded();
|
||||||
releaseGestureWakeLock();
|
releaseGestureWakeLock();
|
||||||
mLaunchCameraOnScreenTurningOn = false;
|
mLaunchCameraOnScreenTurningOn = false;
|
||||||
|
mStartedGoingToSleep = false;
|
||||||
mDeviceInteractive = false;
|
mDeviceInteractive = false;
|
||||||
mWakeUpComingFromTouch = false;
|
mWakeUpComingFromTouch = false;
|
||||||
mWakeUpTouchLocation = null;
|
mWakeUpTouchLocation = null;
|
||||||
mStackScroller.setAnimationsEnabled(false);
|
mStackScroller.setAnimationsEnabled(false);
|
||||||
updateVisibleToUser();
|
updateVisibleToUser();
|
||||||
|
if (mLaunchCameraOnFinishedGoingToSleep) {
|
||||||
|
mLaunchCameraOnFinishedGoingToSleep = false;
|
||||||
|
|
||||||
|
// This gets executed before we will show Keyguard, so post it in order that the state
|
||||||
|
// is correct.
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
onCameraLaunchGestureDetected();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStartedWakingUp() {
|
public void onStartedWakingUp() {
|
||||||
@@ -3936,7 +3959,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void vibrateForCameraGesture() {
|
private void vibrateForCameraGesture() {
|
||||||
mVibrator.vibrate(750L);
|
// Make sure to pass -1 for repeat so VibratorService doesn't stop us when going to sleep.
|
||||||
|
mVibrator.vibrate(new long[] { 0, 750L }, -1 /* repeat */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onScreenTurnedOn() {
|
public void onScreenTurnedOn() {
|
||||||
@@ -4095,6 +4119,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCameraLaunchGestureDetected() {
|
public void onCameraLaunchGestureDetected() {
|
||||||
|
if (mStartedGoingToSleep) {
|
||||||
|
mLaunchCameraOnFinishedGoingToSleep = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!mNotificationPanel.canCameraGestureBeLaunched(
|
if (!mNotificationPanel.canCameraGestureBeLaunched(
|
||||||
mStatusBarKeyguardViewManager.isShowing() && mExpandedVisible)) {
|
mStatusBarKeyguardViewManager.isShowing() && mExpandedVisible)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -164,6 +164,10 @@ public class StatusBarKeyguardViewManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onStartedGoingToSleep() {
|
||||||
|
mPhoneStatusBar.onStartedGoingToSleep();
|
||||||
|
}
|
||||||
|
|
||||||
public void onFinishedGoingToSleep() {
|
public void onFinishedGoingToSleep() {
|
||||||
mDeviceInteractive = false;
|
mDeviceInteractive = false;
|
||||||
mPhoneStatusBar.onFinishedGoingToSleep();
|
mPhoneStatusBar.onFinishedGoingToSleep();
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ public class GestureLauncherService extends SystemService {
|
|||||||
* Whether camera double tap power button gesture is currently enabled;
|
* Whether camera double tap power button gesture is currently enabled;
|
||||||
*/
|
*/
|
||||||
private boolean mCameraDoubleTapPowerEnabled;
|
private boolean mCameraDoubleTapPowerEnabled;
|
||||||
private long mLastPowerDownWhileNonInteractive = 0;
|
private long mLastPowerDownWhileNonInteractive;
|
||||||
|
private long mLastPowerDownWhileInteractive;
|
||||||
|
|
||||||
public GestureLauncherService(Context context) {
|
public GestureLauncherService(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -251,23 +251,30 @@ public class GestureLauncherService extends SystemService {
|
|||||||
|
|
||||||
public boolean interceptPowerKeyDown(KeyEvent event, boolean interactive) {
|
public boolean interceptPowerKeyDown(KeyEvent event, boolean interactive) {
|
||||||
boolean launched = false;
|
boolean launched = false;
|
||||||
|
boolean intercept = false;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (!mCameraDoubleTapPowerEnabled) {
|
if (!mCameraDoubleTapPowerEnabled) {
|
||||||
mLastPowerDownWhileNonInteractive = 0;
|
mLastPowerDownWhileNonInteractive = 0;
|
||||||
|
mLastPowerDownWhileInteractive = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (event.getEventTime() - mLastPowerDownWhileNonInteractive
|
if (event.getEventTime() - mLastPowerDownWhileNonInteractive
|
||||||
< CAMERA_POWER_DOUBLE_TAP_TIME_MS) {
|
< CAMERA_POWER_DOUBLE_TAP_TIME_MS) {
|
||||||
launched = true;
|
launched = true;
|
||||||
|
intercept = true;
|
||||||
|
} else if (event.getEventTime() - mLastPowerDownWhileInteractive
|
||||||
|
< CAMERA_POWER_DOUBLE_TAP_TIME_MS) {
|
||||||
|
launched = true;
|
||||||
}
|
}
|
||||||
mLastPowerDownWhileNonInteractive = interactive ? 0 : event.getEventTime();
|
mLastPowerDownWhileNonInteractive = interactive ? 0 : event.getEventTime();
|
||||||
|
mLastPowerDownWhileInteractive = interactive ? event.getEventTime() : 0;
|
||||||
}
|
}
|
||||||
if (launched) {
|
if (launched) {
|
||||||
Slog.i(TAG, "Power button double tap gesture detected, launching camera.");
|
Slog.i(TAG, "Power button double tap gesture detected, launching camera.");
|
||||||
launched = handleCameraLaunchGesture(false /* useWakelock */,
|
launched = handleCameraLaunchGesture(false /* useWakelock */,
|
||||||
MetricsLogger.ACTION_DOUBLE_TAP_POWER_CAMERA_GESTURE);
|
MetricsLogger.ACTION_DOUBLE_TAP_POWER_CAMERA_GESTURE);
|
||||||
}
|
}
|
||||||
return launched;
|
return intercept && launched;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public class VibratorService extends IVibratorService.Stub
|
|||||||
implements InputManager.InputDeviceListener {
|
implements InputManager.InputDeviceListener {
|
||||||
private static final String TAG = "VibratorService";
|
private static final String TAG = "VibratorService";
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
private static final String SYSTEM_UI_PACKAGE = "com.android.systemui";
|
||||||
|
|
||||||
private final LinkedList<Vibration> mVibrations;
|
private final LinkedList<Vibration> mVibrations;
|
||||||
private final LinkedList<VibrationInfo> mPreviousVibrations;
|
private final LinkedList<VibrationInfo> mPreviousVibrations;
|
||||||
@@ -147,7 +148,8 @@ public class VibratorService extends IVibratorService.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSystemHapticFeedback() {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user