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

Commit 3448c2fe authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Add a method in IDreamManager to check if dreaming OR in dream preview" into tm-qpr-dev

parents a53fd2a5 a652dac6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ interface IDreamManager {
    void testDream(int userId, in ComponentName componentName);
    @UnsupportedAppUsage
    boolean isDreaming();
    @UnsupportedAppUsage
    boolean isDreamingOrInPreview();
    void finishSelf(in IBinder token, boolean immediate);
    void startDozing(in IBinder token, int screenState, int screenBrightness);
    void stopDozing(in IBinder token);
+21 −0
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ public final class DreamManagerService extends SystemService {
        }, pw, "", 200);
    }

    /** Whether a real dream is occurring. */
    private boolean isDreamingInternal() {
        synchronized (mLock) {
            return mCurrentDreamToken != null && !mCurrentDreamIsPreview
@@ -225,6 +226,13 @@ public final class DreamManagerService extends SystemService {
        }
    }

    /** Whether a real dream, or a dream preview is occurring. */
    private boolean isDreamingOrInPreviewInternal() {
        synchronized (mLock) {
            return mCurrentDreamToken != null && !mCurrentDreamIsWaking;
        }
    }

    protected void requestStartDreamFromShell() {
        requestDreamInternal();
    }
@@ -694,6 +702,19 @@ public final class DreamManagerService extends SystemService {
            }
        }

        @Override // Binder call
        public boolean isDreamingOrInPreview() {
            checkPermission(android.Manifest.permission.READ_DREAM_STATE);

            final long ident = Binder.clearCallingIdentity();
            try {
                return isDreamingOrInPreviewInternal();
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        }


        @Override // Binder call
        public void dream() {
            checkPermission(android.Manifest.permission.WRITE_DREAM_STATE);