From 6188843762982aa9c9e533b93f51db77083814c7 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Tue, 1 Nov 2022 13:25:41 -0700 Subject: [PATCH] Add a flag for the bubble bar This is an UnreleasedFlag which is only available in SysUI, so we set it on Bubbles via BubblesManager which is part of SysUI. Changes to support bubble bar will happen behind this flag. Bug: 253318833 Bug: 256873975 Test: manual - enable flag and add a bubble on a large screen device - observe that the bubbles are pinned to the bottom Change-Id: I0d86a71b66db683837bf639d9067d92703b4364e --- .../wm/shell/bubbles/BubbleController.java | 23 ++++++++++++++++++- .../com/android/wm/shell/bubbles/Bubbles.java | 5 ++++ .../systemui/dagger/SystemUIModule.java | 3 +++ .../src/com/android/systemui/flags/Flags.kt | 3 +++ .../systemui/wmshell/BubblesManager.java | 6 +++++ .../android/systemui/wmshell/BubblesTest.java | 2 ++ 6 files changed, 41 insertions(+), 1 deletion(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index 0596be5783ddf..bec6844ae8631 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -150,6 +150,9 @@ public class BubbleController implements ConfigurationChangeListener { private final ShellExecutor mBackgroundExecutor; + // Whether or not we should show bubbles pinned at the bottom of the screen. + private boolean mIsBubbleBarEnabled; + private BubbleLogger mLogger; private BubbleData mBubbleData; @Nullable private BubbleStackView mStackView; @@ -210,7 +213,6 @@ public class BubbleController implements ConfigurationChangeListener { /** Drag and drop controller to register listener for onDragStarted. */ private DragAndDropController mDragAndDropController; - public BubbleController(Context context, ShellInit shellInit, ShellCommandHandler shellCommandHandler, @@ -526,6 +528,12 @@ public class BubbleController implements ConfigurationChangeListener { mDataRepository.removeBubblesForUser(removedUserId, parentUserId); } + // TODO(b/256873975): Should pass this into the constructor once flags are available to shell. + /** Sets whether the bubble bar is enabled (i.e. bubbles pinned to bottom on large screens). */ + public void setBubbleBarEnabled(boolean enabled) { + mIsBubbleBarEnabled = enabled; + } + /** Whether this userId belongs to the current user. */ private boolean isCurrentProfile(int userId) { return userId == UserHandle.USER_ALL @@ -592,6 +600,12 @@ public class BubbleController implements ConfigurationChangeListener { mStackView.setUnbubbleConversationCallback(mSysuiProxy::onUnbubbleConversation); } + if (mIsBubbleBarEnabled && mBubblePositioner.isLargeScreen()) { + mBubblePositioner.setUsePinnedLocation(true); + } else { + mBubblePositioner.setUsePinnedLocation(false); + } + addToWindowManagerMaybe(); } @@ -1794,6 +1808,13 @@ public class BubbleController implements ConfigurationChangeListener { }); } + @Override + public void setBubbleBarEnabled(boolean enabled) { + mMainExecutor.execute(() -> { + BubbleController.this.setBubbleBarEnabled(enabled); + }); + } + @Override public void onNotificationPanelExpandedChanged(boolean expanded) { mMainExecutor.execute( diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java index bb240193c7c48..465d1abe0a3df 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java @@ -242,6 +242,11 @@ public interface Bubbles { */ void onUserRemoved(int removedUserId); + /** + * Sets whether bubble bar should be enabled or not. + */ + void setBubbleBarEnabled(boolean enabled); + /** Listener to find out about stack expansion / collapse events. */ interface BubbleExpandListener { /** diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 6db562107357e..12d2846ddd231 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -41,6 +41,7 @@ import com.android.systemui.demomode.dagger.DemoModeModule; import com.android.systemui.doze.dagger.DozeComponent; import com.android.systemui.dreams.dagger.DreamModule; import com.android.systemui.dump.DumpManager; +import com.android.systemui.flags.FeatureFlags; import com.android.systemui.flags.FlagsModule; import com.android.systemui.fragments.FragmentService; import com.android.systemui.keyguard.data.BouncerViewModule; @@ -240,6 +241,7 @@ public abstract class SystemUIModule { CommonNotifCollection notifCollection, NotifPipeline notifPipeline, SysUiState sysUiState, + FeatureFlags featureFlags, @Main Executor sysuiMainExecutor) { return Optional.ofNullable(BubblesManager.create(context, bubblesOptional, @@ -256,6 +258,7 @@ public abstract class SystemUIModule { notifCollection, notifPipeline, sysUiState, + featureFlags, sysuiMainExecutor)); } diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt index 82894461b63ec..be203e361a6ba 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt +++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt @@ -283,6 +283,9 @@ object Flags { val ENABLE_PIP_KEEP_CLEAR_ALGORITHM = SysPropBooleanFlag(1110, "persist.wm.debug.enable_pip_keep_clear_algorithm", false) + // TODO(b/256873975): Tracking Bug + @JvmField @Keep val WM_BUBBLE_BAR = UnreleasedFlag(1111) + // 1200 - predictive back @JvmField @Keep diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java b/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java index 4e77514645645..a4384d5810ce7 100644 --- a/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java +++ b/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java @@ -25,6 +25,7 @@ import static android.service.notification.NotificationListenerService.REASON_GR import static android.service.notification.NotificationStats.DISMISSAL_BUBBLE; import static android.service.notification.NotificationStats.DISMISS_SENTIMENT_NEUTRAL; +import static com.android.systemui.flags.Flags.WM_BUBBLE_BAR; import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES; import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME; @@ -51,6 +52,7 @@ import androidx.annotation.Nullable; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.statusbar.IStatusBarService; import com.android.systemui.dagger.SysUISingleton; +import com.android.systemui.flags.FeatureFlags; import com.android.systemui.model.SysUiState; import com.android.systemui.shade.ShadeController; import com.android.systemui.shared.system.QuickStepContract; @@ -129,6 +131,7 @@ public class BubblesManager { CommonNotifCollection notifCollection, NotifPipeline notifPipeline, SysUiState sysUiState, + FeatureFlags featureFlags, Executor sysuiMainExecutor) { if (bubblesOptional.isPresent()) { return new BubblesManager(context, @@ -146,6 +149,7 @@ public class BubblesManager { notifCollection, notifPipeline, sysUiState, + featureFlags, sysuiMainExecutor); } else { return null; @@ -168,6 +172,7 @@ public class BubblesManager { CommonNotifCollection notifCollection, NotifPipeline notifPipeline, SysUiState sysUiState, + FeatureFlags featureFlags, Executor sysuiMainExecutor) { mContext = context; mBubbles = bubbles; @@ -352,6 +357,7 @@ public class BubblesManager { }); } }; + mBubbles.setBubbleBarEnabled(featureFlags.isEnabled(WM_BUBBLE_BAR)); mBubbles.setSysuiProxy(mSysuiProxy); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java index fa7ebf6a2449f..bee882d438496 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java @@ -86,6 +86,7 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.biometrics.AuthController; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dump.DumpManager; +import com.android.systemui.flags.FeatureFlags; import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.model.SysUiState; import com.android.systemui.plugins.statusbar.StatusBarStateController; @@ -394,6 +395,7 @@ public class BubblesTest extends SysuiTestCase { mCommonNotifCollection, mNotifPipeline, mSysUiState, + mock(FeatureFlags.class), syncExecutor); mBubblesManager.addNotifCallback(mNotifCallback);