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

Commit 3ca5f931 authored by Luca Stefani's avatar Luca Stefani Committed by grepfox
Browse files

SystemUIProxy: Add onSleepEvent

Will make device sleep peacefully at night.

Change-Id: Ifaba317a76640362286f303798125a21b4af243b
parent ee7811df
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -195,5 +195,10 @@ interface ISystemUiProxy {
     */
    oneway void onKeyEvent(int keycode, int displayId) = 60;

    // Next id = 61
    /**
     * Notifies SystemUI of a double tap to sleep event.
     */
    oneway void onSleepEvent(in MotionEvent event) = 61;

    // Next id = 62
}
+12 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import android.os.IBinder;
import android.os.IRemoteCallback;
import android.os.Looper;
import android.os.PatternMatcher;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.Trace;
@@ -524,6 +525,17 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis
                    mCommandQueue.toggleQuickSettingsPanel());
        }

        @Override
        public void onSleepEvent(MotionEvent event) {
            verifyCallerAndClearCallingIdentity("onSleepEvent", () -> {
                mHandler.post(() -> {
                    mContext.getSystemService(PowerManager.class)
                            .goToSleep(event.getEventTime());
                    event.recycle();
                });
            });
        }

        private void onShadeExpansionGesture(MotionEvent event, String reason) {
            if (!SceneContainerFlag.isEnabled()) {
                return;