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

Commit 18fb3cee authored by Bryce Lee's avatar Bryce Lee
Browse files

Send preview state to DreamOverlayService.

This changelist sends the preview state from DreamService to
DreamOverlayService.

Bug: 333734282
Flag: android.service.dreams.publish_preview_state_to_overlay
Test: atest DreamOverlayServiceTest#testOverlayClientInteraction
Change-Id: Id2987dce4a49964708a97f98cbb3ce20bbc1ff5b
parent 1f4bce7d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3138,6 +3138,7 @@ package android.service.dreams {

  public abstract class DreamOverlayService extends android.app.Service {
    ctor public DreamOverlayService();
    method @FlaggedApi("android.service.dreams.publish_preview_state_to_overlay") public final boolean isDreamInPreviewMode();
    method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent);
    method public void onEndDream();
    method public abstract void onStartDream(@NonNull android.view.WindowManager.LayoutParams);
+21 −2
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ public abstract class DreamOverlayService extends Service {
    private static class OverlayClient extends IDreamOverlayClient.Stub {
        private final WeakReference<DreamOverlayService> mService;
        private boolean mShowComplications;
        private boolean mIsPreview;
        private ComponentName mDreamComponent;
        IDreamOverlayCallback mDreamOverlayCallback;

@@ -75,9 +76,11 @@ public abstract class DreamOverlayService extends Service {

        @Override
        public void startDream(WindowManager.LayoutParams params, IDreamOverlayCallback callback,
                String dreamComponent, boolean shouldShowComplications) throws RemoteException {
                String dreamComponent, boolean isPreview, boolean shouldShowComplications)
                throws RemoteException {
            mDreamComponent = ComponentName.unflattenFromString(dreamComponent);
            mShowComplications = shouldShowComplications;
            mIsPreview = isPreview;
            mDreamOverlayCallback = callback;
            applyToDream(dreamOverlayService -> dreamOverlayService.startDream(this, params));
        }
@@ -124,6 +127,10 @@ public abstract class DreamOverlayService extends Service {
            return mShowComplications;
        }

        private boolean isDreamInPreviewMode() {
            return mIsPreview;
        }

        private ComponentName getComponent() {
            return mDreamComponent;
        }
@@ -303,7 +310,6 @@ public abstract class DreamOverlayService extends Service {
     *
     * @hide
     */
    @FlaggedApi(Flags.FLAG_DREAM_WAKE_REDIRECT)
    public void onWakeRequested() {
    }

@@ -319,6 +325,19 @@ public abstract class DreamOverlayService extends Service {
        return mCurrentClient.shouldShowComplications();
    }

    /**
     * Returns whether dream is in preview mode.
     */
    @FlaggedApi(Flags.FLAG_PUBLISH_PREVIEW_STATE_TO_OVERLAY)
    public final boolean isDreamInPreviewMode() {
        if (mCurrentClient == null) {
            throw new IllegalStateException(
                    "requested if preview when no dream active");
        }

        return mCurrentClient.isDreamInPreviewMode();
    }

    /**
     * Returns the active dream component.
     * @hide
+1 −0
Original line number Diff line number Diff line
@@ -1701,6 +1701,7 @@ public class DreamService extends Service implements Window.Callback {
                                try {
                                    overlay.startDream(mWindow.getAttributes(), mOverlayCallback,
                                            mDreamComponent.flattenToString(),
                                            mPreviewMode,
                                            mShouldShowComplications);
                                } catch (RemoteException e) {
                                    Log.e(mTag, "could not send window attributes:" + e);
+2 −1
Original line number Diff line number Diff line
@@ -31,11 +31,12 @@ interface IDreamOverlayClient {
    * @param callback The {@link IDreamOverlayCallback} for requesting actions such as exiting the
    *                dream.
    * @param dreamComponent The component name of the dream service requesting overlay.
    * @param isPreview Whether the dream is in preview mode.
    * @param shouldShowComplications Whether the dream overlay should show complications, e.g. clock
    *                and weather.
    */
    void startDream(in LayoutParams params, in IDreamOverlayCallback callback,
        in String dreamComponent, in boolean shouldShowComplications);
        in String dreamComponent, in boolean isPreview, in boolean shouldShowComplications);

    /** Called when the dream is waking, to do any exit animations */
    void wakeUp();
+10 −0
Original line number Diff line number Diff line
@@ -57,3 +57,13 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "publish_preview_state_to_overlay"
    namespace: "systemui"
    description: "send preview information from dream to overlay"
    bug: "333734282"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
Loading