Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 347bb9a3 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Don't lock device when double tapping" into nyc-dev

parents 50e229f1 f1cdf955
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -51,8 +51,11 @@ oneway interface IKeyguardService {
     *
     * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
     *            or {@link #OFF_BECAUSE_OF_TIMEOUT}.
     * @param cameraGestureTriggered whether the camera gesture was triggered between
     *                               {@link #onStartedGoingToSleep} and this method; if it's been
     *                               triggered, we shouldn't lock the device.
     */
    void onFinishedGoingToSleep(int reason);
    void onFinishedGoingToSleep(int reason, boolean cameraGestureTriggered);

    /**
     * Called when the device has started waking up.
+2 −2
Original line number Diff line number Diff line
@@ -115,9 +115,9 @@ public class KeyguardService extends Service {
        }

        @Override // Binder interface
        public void onFinishedGoingToSleep(int reason) {
        public void onFinishedGoingToSleep(int reason, boolean cameraGestureTriggered) {
            checkPermission();
            mKeyguardViewMediator.onFinishedGoingToSleep(reason);
            mKeyguardViewMediator.onFinishedGoingToSleep(reason, cameraGestureTriggered);
        }

        @Override // Binder interface
+12 −2
Original line number Diff line number Diff line
@@ -747,7 +747,7 @@ public class KeyguardViewMediator extends SystemUI {
        notifyStartedGoingToSleep();
    }

    public void onFinishedGoingToSleep(int why) {
    public void onFinishedGoingToSleep(int why, boolean cameraGestureTriggered) {
        if (DEBUG) Log.d(TAG, "onFinishedGoingToSleep(" + why + ")");
        synchronized (this) {
            mDeviceInteractive = false;
@@ -758,6 +758,16 @@ public class KeyguardViewMediator extends SystemUI {

            notifyFinishedGoingToSleep();

            if (cameraGestureTriggered) {
                Log.i(TAG, "Camera gesture was triggered, preventing Keyguard locking.");

                // Just to make sure, make sure the device is awake.
                mContext.getSystemService(PowerManager.class).wakeUp(SystemClock.uptimeMillis(),
                        "com.android.systemui:CAMERA_GESTURE_PREVENT_LOCK");
                mPendingLock = false;
                mPendingReset = false;
            }

            if (mPendingReset) {
                resetStateLocked();
                mPendingReset = false;
@@ -771,7 +781,7 @@ public class KeyguardViewMediator extends SystemUI {
            // We do not have timeout and power button instant lock setting for profile lock.
            // So we use the personal setting if there is any. But if there is no device
            // we need to make sure we lock it immediately when the screen is off.
            if (!mLockLater) {
            if (!mLockLater && !cameraGestureTriggered) {
                doKeyguardForChildProfilesLocked();
            }

+4 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.os.PowerManager.WakeLock;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.MutableBoolean;
import android.util.Slog;
import android.view.KeyEvent;

@@ -251,7 +252,8 @@ public class GestureLauncherService extends SystemService {
        return isCameraLaunchEnabled(resources) || isCameraDoubleTapPowerEnabled(resources);
    }

    public boolean interceptPowerKeyDown(KeyEvent event, boolean interactive) {
    public boolean interceptPowerKeyDown(KeyEvent event, boolean interactive,
            MutableBoolean outLaunched) {
        boolean launched = false;
        boolean intercept = false;
        long doubleTapInterval;
@@ -276,6 +278,7 @@ public class GestureLauncherService extends SystemService {
            }
        }
        MetricsLogger.histogram(mContext, "power_double_tap_interval", (int) doubleTapInterval);
        outLaunched.value = launched;
        return intercept && launched;
    }

+16 −2
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ import android.telecom.TelecomManager;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.Log;
import android.util.MutableBoolean;
import android.util.Slog;
import android.util.SparseArray;
import android.util.LongSparseArray;
@@ -396,6 +397,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    volatile boolean mBeganFromNonInteractive;
    volatile int mPowerKeyPressCounter;
    volatile boolean mEndCallKeyHandled;
    volatile boolean mCameraGestureTriggeredDuringGoingToSleep;
    volatile boolean mGoingToSleep;

    boolean mRecentsVisible;
    int mRecentAppsHeldModifiers;
@@ -685,6 +688,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            = new LogDecelerateInterpolator(100, 0);

    private boolean mForceWindowDrawsStatusBarBackground;
    private final MutableBoolean mTmpBoolean = new MutableBoolean(false);

    private static final int MSG_ENABLE_POINTER_LOCATION = 1;
    private static final int MSG_DISABLE_POINTER_LOCATION = 2;
@@ -1032,7 +1036,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                GestureLauncherService.class);
        boolean gesturedServiceIntercepted = false;
        if (gestureService != null) {
            gesturedServiceIntercepted = gestureService.interceptPowerKeyDown(event, interactive);
            gesturedServiceIntercepted = gestureService.interceptPowerKeyDown(event, interactive,
                    mTmpBoolean);
            if (mTmpBoolean.value && mGoingToSleep) {
                mCameraGestureTriggeredDuringGoingToSleep = true;
            }
        }

        // If the power key has still not yet been handled, then detect short
@@ -5954,6 +5962,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    @Override
    public void startedGoingToSleep(int why) {
        if (DEBUG_WAKEUP) Slog.i(TAG, "Started going to sleep... (why=" + why + ")");
        mCameraGestureTriggeredDuringGoingToSleep = false;
        mGoingToSleep = true;
        if (mKeyguardDelegate != null) {
            mKeyguardDelegate.onStartedGoingToSleep(why);
        }
@@ -5966,6 +5976,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (DEBUG_WAKEUP) Slog.i(TAG, "Finished going to sleep... (why=" + why + ")");
        MetricsLogger.histogram(mContext, "screen_timeout", mLockScreenTimeout / 1000);

        mGoingToSleep = false;

        // We must get this work done here because the power manager will drop
        // the wake lock and let the system suspend once this function returns.
        synchronized (mLock) {
@@ -5975,8 +5987,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            updateLockScreenTimeout();
        }
        if (mKeyguardDelegate != null) {
            mKeyguardDelegate.onFinishedGoingToSleep(why);
            mKeyguardDelegate.onFinishedGoingToSleep(why,
                    mCameraGestureTriggeredDuringGoingToSleep);
        }
        mCameraGestureTriggeredDuringGoingToSleep = false;
    }

    // Called on the PowerManager's Notifier thread.
Loading