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

Commit 08aed043 authored by jt1134's avatar jt1134 Committed by Gerrit Code Review
Browse files

LockScreen: allow hardware key longpress to put device to sleep

Change-Id: I54260e21c462bcabd9b6383e22f44d644630b4d3
parent ac9ebd28
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.graphics.Rect;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
import android.os.PowerManager;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Vibrator;
@@ -255,6 +256,9 @@ public class KeyguardViewManager {
        } else if ("SOUND".equals(uri)) {
            toggleSilentMode(context);
            return true;
        } else if ("SLEEP".equals(uri)) {
            sendToSleep(context);
            return true;
        }

        return false;
@@ -307,6 +311,12 @@ public class KeyguardViewManager {
        return pattern;
    }

    private static void sendToSleep(Context context) {
        final PowerManager pm;
        pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        pm.goToSleep(SystemClock.uptimeMillis());
    }

    SparseArray<Parcelable> mStateContainer = new SparseArray<Parcelable>();

    private void maybeCreateKeyguardLocked(boolean enableScreenRotation, boolean force,