From b89dfa9c75f0c218d8863b769eef0aca679a58d5 Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Wed, 22 Feb 2023 16:41:44 -0800 Subject: [PATCH] Set dream overlay window title to System UI. This changelist updates the window title for the dream overlay to match the System UI app label. Test: manual with TalkBack Fixes: 267837462 Change-Id: I319a3fdb3bad0f852501c20a588cc10c2621c55e --- .../android/systemui/dreams/DreamOverlayService.java | 9 +++++++-- .../android/systemui/dreams/dagger/DreamModule.java | 10 ++++++++++ .../systemui/dreams/DreamOverlayServiceTest.java | 4 +++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java index 5aebc3268b90b..c8c5c9526df95 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java @@ -16,6 +16,8 @@ package com.android.systemui.dreams; +import static com.android.systemui.dreams.dagger.DreamModule.DREAM_OVERLAY_WINDOW_TITLE; + import android.content.ComponentName; import android.content.Context; import android.graphics.drawable.ColorDrawable; @@ -70,6 +72,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ private final ComponentName mLowLightDreamComponent; private final UiEventLogger mUiEventLogger; private final WindowManager mWindowManager; + private final String mWindowTitle; // A reference to the {@link Window} used to hold the dream overlay. private Window mWindow; @@ -134,7 +137,8 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ UiEventLogger uiEventLogger, @Nullable @Named(LowLightDreamModule.LOW_LIGHT_DREAM_COMPONENT) ComponentName lowLightDreamComponent, - DreamOverlayCallbackController dreamOverlayCallbackController) { + DreamOverlayCallbackController dreamOverlayCallbackController, + @Named(DREAM_OVERLAY_WINDOW_TITLE) String windowTitle) { mContext = context; mExecutor = executor; mWindowManager = windowManager; @@ -144,6 +148,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ mStateController = stateController; mUiEventLogger = uiEventLogger; mDreamOverlayCallbackController = dreamOverlayCallbackController; + mWindowTitle = windowTitle; final ViewModelStore viewModelStore = new ViewModelStore(); final Complication.Host host = @@ -244,7 +249,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ private void addOverlayWindowLocked(WindowManager.LayoutParams layoutParams) { mWindow = new PhoneWindow(mContext); // Default to SystemUI name for TalkBack. - mWindow.setTitle(""); + mWindow.setTitle(mWindowTitle); mWindow.setAttributes(layoutParams); mWindow.setWindowManager(null, layoutParams.token, "DreamOverlay", true); diff --git a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java index 88c02b8aa790c..8cfc366e83dab 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java @@ -23,6 +23,7 @@ import android.content.res.Resources; import com.android.dream.lowlight.dagger.LowLightDreamModule; import com.android.settingslib.dream.DreamBackend; +import com.android.systemui.R; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dreams.DreamOverlayNotificationCountProvider; @@ -63,6 +64,8 @@ public interface DreamModule { String DREAM_SUPPORTED = "dream_supported"; String DREAM_PRETEXT_CONDITIONS = "dream_pretext_conditions"; String DREAM_PRETEXT_MONITOR = "dream_prtext_monitor"; + String DREAM_OVERLAY_WINDOW_TITLE = "dream_overlay_window_title"; + /** * Provides the dream component @@ -136,4 +139,11 @@ public interface DreamModule { @Named(DREAM_PRETEXT_CONDITIONS) Set pretextConditions) { return new Monitor(executor, pretextConditions); } + + /** */ + @Provides + @Named(DREAM_OVERLAY_WINDOW_TITLE) + static String providesDreamOverlayWindowTitle(@Main Resources resources) { + return resources.getString(R.string.app_label); + } } 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 dfb4d5baeef5f..e4516320e472b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java @@ -69,6 +69,7 @@ public class DreamOverlayServiceTest extends SysuiTestCase { private static final ComponentName LOW_LIGHT_COMPONENT = new ComponentName("package", "lowlight"); private static final String DREAM_COMPONENT = "package/dream"; + private static final String WINDOW_NAME = "test"; private final FakeSystemClock mFakeSystemClock = new FakeSystemClock(); private final FakeExecutor mMainExecutor = new FakeExecutor(mFakeSystemClock); @@ -148,7 +149,8 @@ public class DreamOverlayServiceTest extends SysuiTestCase { mKeyguardUpdateMonitor, mUiEventLogger, LOW_LIGHT_COMPONENT, - mDreamOverlayCallbackController); + mDreamOverlayCallbackController, + WINDOW_NAME); } public IDreamOverlayClient getClient() throws RemoteException {