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

Commit a652dac6 authored by Mady Mellor's avatar Mady Mellor
Browse files

Add a method in IDreamManager to check if dreaming OR in dream preview

Currently there is no signal to identify that dreaming has started
from the 'preview' option in screen saver settings. This adds a
way to query IDreamManager for this state.

Bubbles needs a way to identify this so that they can hide when
the dream preview starts, otherwise it wouldn't be an accurate
preview.

Bug: 240510360
Test: manual - (with the CL on top of this), have some bubbles and
      trigger dream preview, observe that the bubbles hide.
Change-Id: I5f67a8c793970ada05a010c8d36fd4a47b3f8565
parent 889241a5
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);