summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/test-current.txt1
-rw-r--r--core/java/android/service/dreams/DreamOverlayService.java23
-rw-r--r--core/java/android/service/dreams/DreamService.java1
-rw-r--r--core/java/android/service/dreams/IDreamOverlayClient.aidl3
-rw-r--r--core/java/android/service/dreams/flags.aconfig10
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt32
-rw-r--r--services/tests/dreamservicetests/src/com/android/server/dreams/DreamOverlayServiceTest.java12
-rw-r--r--services/tests/dreamservicetests/src/com/android/server/dreams/TestDreamEnvironment.java3
8 files changed, 76 insertions, 9 deletions
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 0a35c5a36325..009d08245da2 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -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);
diff --git a/core/java/android/service/dreams/DreamOverlayService.java b/core/java/android/service/dreams/DreamOverlayService.java
index fc6af7b15c97..711c41498929 100644
--- a/core/java/android/service/dreams/DreamOverlayService.java
+++ b/core/java/android/service/dreams/DreamOverlayService.java
@@ -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() {
}
@@ -320,6 +326,19 @@ public abstract class DreamOverlayService extends Service {
}
/**
+ * 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
*/
diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java
index c3585e3c5288..ce31e1ea7e38 100644
--- a/core/java/android/service/dreams/DreamService.java
+++ b/core/java/android/service/dreams/DreamService.java
@@ -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);
diff --git a/core/java/android/service/dreams/IDreamOverlayClient.aidl b/core/java/android/service/dreams/IDreamOverlayClient.aidl
index 0eb15a07edf7..e9df402c6d07 100644
--- a/core/java/android/service/dreams/IDreamOverlayClient.aidl
+++ b/core/java/android/service/dreams/IDreamOverlayClient.aidl
@@ -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();
diff --git a/core/java/android/service/dreams/flags.aconfig b/core/java/android/service/dreams/flags.aconfig
index 83e0adfca3be..72f2de805474 100644
--- a/core/java/android/service/dreams/flags.aconfig
+++ b/core/java/android/service/dreams/flags.aconfig
@@ -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
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt
index eda9039c748e..3f2faeb40eeb 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt
@@ -315,6 +315,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -332,6 +333,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -351,6 +353,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -373,6 +376,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -391,6 +395,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -406,6 +411,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
true /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -421,6 +427,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
LOW_LIGHT_COMPONENT.flattenToString(),
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -437,6 +444,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
HOME_CONTROL_PANEL_DREAM_COMPONENT.flattenToString(),
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -453,6 +461,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
LOW_LIGHT_COMPONENT.flattenToString(),
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -487,6 +496,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
// Immediately end the dream.
@@ -518,6 +528,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -537,6 +548,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
LOW_LIGHT_COMPONENT.flattenToString(),
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -588,6 +600,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -611,6 +624,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -631,6 +645,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
true /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -660,6 +675,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
true /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -683,6 +699,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -708,6 +725,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -733,6 +751,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
// Set communal available, verify that overlay callback is informed.
@@ -761,6 +780,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
true /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -781,6 +801,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
true /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -800,6 +821,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
true /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -823,6 +845,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -853,6 +876,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
testScope.runCurrent()
@@ -869,6 +893,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -892,6 +917,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -923,6 +949,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -954,6 +981,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -989,6 +1017,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -1023,6 +1052,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -1042,6 +1072,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
@@ -1077,6 +1108,7 @@ class DreamOverlayServiceTest : SysuiTestCase() {
mWindowParams,
mDreamOverlayCallback,
DREAM_COMPONENT,
+ false /*isPreview*/,
false /*shouldShowComplication*/
)
mMainExecutor.runAllReady()
diff --git a/services/tests/dreamservicetests/src/com/android/server/dreams/DreamOverlayServiceTest.java b/services/tests/dreamservicetests/src/com/android/server/dreams/DreamOverlayServiceTest.java
index 698ce13aa6db..1abc557c8cce 100644
--- a/services/tests/dreamservicetests/src/com/android/server/dreams/DreamOverlayServiceTest.java
+++ b/services/tests/dreamservicetests/src/com/android/server/dreams/DreamOverlayServiceTest.java
@@ -140,7 +140,7 @@ public class DreamOverlayServiceTest {
// Start the dream.
client.startDream(mLayoutParams, mOverlayCallback,
- FIRST_DREAM_COMPONENT.flattenToString(), false);
+ FIRST_DREAM_COMPONENT.flattenToString(), false, false);
// The callback should not have run yet.
verify(monitor, never()).onStartDream();
@@ -198,22 +198,24 @@ public class DreamOverlayServiceTest {
// Start a dream with the first client and ensure the dream is now active from the
// overlay's perspective.
firstClient.startDream(mLayoutParams, mOverlayCallback,
- FIRST_DREAM_COMPONENT.flattenToString(), false);
+ FIRST_DREAM_COMPONENT.flattenToString(), true, false);
verify(monitor).onStartDream();
assertThat(service.getDreamComponent()).isEqualTo(FIRST_DREAM_COMPONENT);
+ assertThat(service.isDreamInPreviewMode()).isTrue();
Mockito.clearInvocations(monitor);
// Start a dream from the second client and verify that the overlay has both cycled to
// the new dream (ended/started).
secondClient.startDream(mLayoutParams, mOverlayCallback,
- SECOND_DREAM_COMPONENT.flattenToString(), false);
+ SECOND_DREAM_COMPONENT.flattenToString(), false, false);
verify(monitor).onEndDream();
verify(monitor).onStartDream();
assertThat(service.getDreamComponent()).isEqualTo(SECOND_DREAM_COMPONENT);
+ assertThat(service.isDreamInPreviewMode()).isFalse();
Mockito.clearInvocations(monitor);
@@ -248,7 +250,7 @@ public class DreamOverlayServiceTest {
// Start the dream.
client.startDream(mLayoutParams, mOverlayCallback,
- FIRST_DREAM_COMPONENT.flattenToString(), false);
+ FIRST_DREAM_COMPONENT.flattenToString(), false, false);
// Make sure redirect state is set on dream.
verify(mOverlayCallback).onRedirectWake(eq(true));
@@ -262,7 +264,7 @@ public class DreamOverlayServiceTest {
service.redirectWake(true);
clearInvocations(mOverlayCallback);
client.startDream(mLayoutParams, mOverlayCallback,
- FIRST_DREAM_COMPONENT.flattenToString(), false);
+ FIRST_DREAM_COMPONENT.flattenToString(), false, false);
verify(mOverlayCallback).onRedirectWake(eq(true));
}
diff --git a/services/tests/dreamservicetests/src/com/android/server/dreams/TestDreamEnvironment.java b/services/tests/dreamservicetests/src/com/android/server/dreams/TestDreamEnvironment.java
index 43aa7fe46ca5..7c239ef02e58 100644
--- a/services/tests/dreamservicetests/src/com/android/server/dreams/TestDreamEnvironment.java
+++ b/services/tests/dreamservicetests/src/com/android/server/dreams/TestDreamEnvironment.java
@@ -385,7 +385,8 @@ public class TestDreamEnvironment {
final ArgumentCaptor<IDreamOverlayCallback> overlayCallbackCaptor =
ArgumentCaptor.forClass(IDreamOverlayCallback.class);
verify(mDreamOverlayClient, description("dream client not informed of dream start"))
- .startDream(any(), overlayCallbackCaptor.capture(), any(), anyBoolean());
+ .startDream(any(), overlayCallbackCaptor.capture(), any(), anyBoolean(),
+ anyBoolean());
mDreamOverlayCallback = overlayCallbackCaptor.getValue();
}