diff --git a/core/api/test-current.txt b/core/api/test-current.txt index cb90f6c15b71e..66250fcebe926 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -2320,6 +2320,7 @@ package android.service.dreams { method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent); method public abstract void onStartDream(@NonNull android.view.WindowManager.LayoutParams); method public final void requestExit(); + method public final boolean shouldShowComplications(); } } diff --git a/core/java/android/service/dreams/DreamOverlayService.java b/core/java/android/service/dreams/DreamOverlayService.java index 50f9d8ac29581..163d6ed4b18ba 100644 --- a/core/java/android/service/dreams/DreamOverlayService.java +++ b/core/java/android/service/dreams/DreamOverlayService.java @@ -35,6 +35,7 @@ import android.view.WindowManager; public abstract class DreamOverlayService extends Service { private static final String TAG = "DreamOverlayService"; private static final boolean DEBUG = false; + private boolean mShowComplications; private IDreamOverlay mDreamOverlay = new IDreamOverlay.Stub() { @Override @@ -53,6 +54,8 @@ public abstract class DreamOverlayService extends Service { @Nullable @Override public final IBinder onBind(@NonNull Intent intent) { + mShowComplications = intent.getBooleanExtra(DreamService.EXTRA_SHOW_COMPLICATIONS, + DreamService.DEFAULT_SHOW_COMPLICATIONS); return mDreamOverlay.asBinder(); } @@ -74,4 +77,11 @@ public abstract class DreamOverlayService extends Service { Log.e(TAG, "Could not request exit:" + e); } } + + /** + * Returns whether to show complications on the dream overlay. + */ + public final boolean shouldShowComplications() { + return mShowComplications; + } } diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java index 4ae3d7de26c2a..133e384dfa8fe 100644 --- a/core/java/android/service/dreams/DreamService.java +++ b/core/java/android/service/dreams/DreamService.java @@ -189,6 +189,19 @@ public class DreamService extends Service implements Window.Callback { */ public static final String DREAM_META_DATA = "android.service.dream"; + /** + * Extra containing a boolean for whether to show complications on the overlay. + * @hide + */ + public static final String EXTRA_SHOW_COMPLICATIONS = + "android.service.dreams.SHOW_COMPLICATIONS"; + + /** + * The default value for whether to show complications on the overlay. + * @hide + */ + public static final boolean DEFAULT_SHOW_COMPLICATIONS = true; + private final IDreamManager mDreamManager; private final Handler mHandler = new Handler(Looper.getMainLooper()); private IBinder mDreamToken; diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java index 8cd8e4d7382df..c0b7271c6de76 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java @@ -16,12 +16,15 @@ package com.android.systemui.dreams; +import static com.google.common.truth.Truth.assertThat; + import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Intent; import android.os.IBinder; +import android.service.dreams.DreamService; import android.service.dreams.IDreamOverlay; import android.service.dreams.IDreamOverlayCallback; import android.testing.AndroidTestingRunner; @@ -195,4 +198,22 @@ public class DreamOverlayServiceTest extends SysuiTestCase { mService.onDestroy(); verify(mDreamOverlayStateController).removeCallback(callbackCapture.getValue()); } + + @Test + public void testShouldShowComplicationsTrueByDefault() { + assertThat(mService.shouldShowComplications()).isTrue(); + + mService.onBind(new Intent()); + + assertThat(mService.shouldShowComplications()).isTrue(); + } + + @Test + public void testShouldShowComplicationsSetByIntentExtra() { + final Intent intent = new Intent(); + intent.putExtra(DreamService.EXTRA_SHOW_COMPLICATIONS, false); + mService.onBind(intent); + + assertThat(mService.shouldShowComplications()).isFalse(); + } }