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

Commit 4ad02d32 authored by Christopher R. Palmer's avatar Christopher R. Palmer Committed by Steve Kondik
Browse files

ambient display: Fix volume key music control

Previously the dream service would only report whether or not it was dreaming.
Ambient display counts as dreaming.  When dreaming, the volume inputs are
passed back to the application which is not what we want for ambient
display.

Fix this by exposing isDozing() and allow volume keys to control music
when we are dreaming and have moved into doze mode (aka, sleeping).

Change-Id: I3b1e72b95ec8b1b63ef0219259dfee77a5d339d3
parent da347492
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -42,4 +42,9 @@ public abstract class DreamManagerInternal {
     * Called by the power manager to determine whether a dream is running.
     */
    public abstract boolean isDreaming();

    /**
     * Called by the power manager to determine whether the dream has gone to doze mode.
     */
    public abstract boolean isDozing();
}
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ interface IDreamManager {
    ComponentName getDefaultDreamComponent();
    void testDream(in ComponentName componentName);
    boolean isDreaming();
    boolean isDozing();
    void finishSelf(in IBinder token, boolean immediate);
    void startDozing(in IBinder token, int screenState, int screenBrightness);
    void stopDozing(in IBinder token);
+1 −1
Original line number Diff line number Diff line
@@ -5787,7 +5787,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        IDreamManager dreamManager = getDreamManager();

        try {
            if (dreamManager != null && dreamManager.isDreaming()) {
            if (dreamManager != null && dreamManager.isDreaming() && !dreamManager.isDozing()) {
                return true;
            }
        } catch (RemoteException e) {
+23 −0
Original line number Diff line number Diff line
@@ -150,6 +150,12 @@ public final class DreamManagerService extends SystemService {
        }
    }

    private boolean isDozingInternal() {
        synchronized (mLock) {
            return mCurrentDreamIsDozing;
        }
    }

    private void requestDreamInternal() {
        // Ask the power manager to nap.  It will eventually call back into
        // startDream() if/when it is appropriate to start dreaming.
@@ -529,6 +535,18 @@ public final class DreamManagerService extends SystemService {
            }
        }

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

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

        @Override // Binder call
        public void dream() {
            checkPermission(android.Manifest.permission.WRITE_DREAM_STATE);
@@ -638,6 +656,11 @@ public final class DreamManagerService extends SystemService {
        public boolean isDreaming() {
            return isDreamingInternal();
        }

        @Override
        public boolean isDozing() {
            return isDozingInternal();
        }
    }

    private final Runnable mSystemPropertiesChanged = new Runnable() {