Loading packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java +3 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.provider.VisualStabilityProvider; import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager; import com.android.systemui.statusbar.phone.DozeServiceHost; import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; Loading Loading @@ -174,6 +175,7 @@ public abstract class SystemUIDefaultModule { StatusBarStateController statusBarStateController, KeyguardBypassController bypassController, GroupMembershipManager groupManager, VisualStabilityProvider visualStabilityProvider, ConfigurationController configurationController) { return new HeadsUpManagerPhone( context, Loading @@ -181,6 +183,7 @@ public abstract class SystemUIDefaultModule { statusBarStateController, bypassController, groupManager, visualStabilityProvider, configurationController ); } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/VisualStabilityProvider.kt +36 −4 Original line number Diff line number Diff line package com.android.systemui.statusbar.notification.collection.provider import android.util.ArraySet import com.android.systemui.dagger.SysUISingleton import com.android.systemui.util.ListenerSet import javax.inject.Inject @SysUISingleton class VisualStabilityProvider @Inject constructor() { private val listeners = ListenerSet<OnReorderingAllowedListener>() /** All persistent and temporary listeners, in the order they were added */ private val allListeners = ListenerSet<OnReorderingAllowedListener>() /** The subset of active listeners which are temporary (will be removed after called) */ private val temporaryListeners = ArraySet<OnReorderingAllowedListener>() var isReorderingAllowed = true set(value) { if (field != value) { field = value if (value) { listeners.forEach(OnReorderingAllowedListener::onReorderingAllowed) notifyReorderingAllowed() } } } private fun notifyReorderingAllowed() { allListeners.forEach { listener -> if (temporaryListeners.remove(listener)) { allListeners.remove(listener) } listener.onReorderingAllowed() } } fun addPersistentReorderingAllowedListener(listener: OnReorderingAllowedListener) = listeners.addIfAbsent(listener) /** Add a listener which will be called until it is explicitly removed. */ fun addPersistentReorderingAllowedListener(listener: OnReorderingAllowedListener) { temporaryListeners.remove(listener) allListeners.addIfAbsent(listener) } /** Add a listener which will be removed when it is called. */ fun addTemporaryReorderingAllowedListener(listener: OnReorderingAllowedListener) { // Only add to the temporary set if it was added to the global set // to keep permanent listeners permanent if (allListeners.addIfAbsent(listener)) { temporaryListeners.add(listener) } } /** Remove a listener from receiving any callbacks, whether it is persistent or temporary. */ fun removeReorderingAllowedListener(listener: OnReorderingAllowedListener) { temporaryListeners.remove(listener) allListeners.remove(listener) } } fun interface OnReorderingAllowedListener { Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +13 −16 Original line number Diff line number Diff line Loading @@ -33,7 +33,8 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; import com.android.systemui.statusbar.notification.collection.provider.OnReorderingAllowedListener; import com.android.systemui.statusbar.notification.collection.provider.VisualStabilityProvider; import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.policy.ConfigurationController; Loading @@ -52,7 +53,7 @@ import java.util.Stack; * A implementation of HeadsUpManager for phone and car. */ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, VisualStabilityManager.Callback, OnHeadsUpChangedListener { OnHeadsUpChangedListener { private static final String TAG = "HeadsUpManagerPhone"; @VisibleForTesting Loading @@ -60,8 +61,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, private final KeyguardBypassController mBypassController; private final GroupMembershipManager mGroupMembershipManager; private final List<OnHeadsUpPhoneListenerChange> mHeadsUpPhoneListeners = new ArrayList<>(); // TODO (b/162832756): remove visual stability manager when migrating to new pipeline private VisualStabilityManager mVisualStabilityManager; private final VisualStabilityProvider mVisualStabilityProvider; private boolean mReleaseOnExpandFinish; private boolean mTrackingHeadsUp; Loading Loading @@ -104,6 +104,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, StatusBarStateController statusBarStateController, KeyguardBypassController bypassController, GroupMembershipManager groupMembershipManager, VisualStabilityProvider visualStabilityProvider, ConfigurationController configurationController) { super(context, logger); Resources resources = mContext.getResources(); Loading @@ -111,6 +112,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, statusBarStateController.addCallback(mStatusBarStateListener); mBypassController = bypassController; mGroupMembershipManager = groupMembershipManager; mVisualStabilityProvider = visualStabilityProvider; updateResources(); configurationController.addCallback(new ConfigurationController.ConfigurationListener() { Loading @@ -126,10 +128,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, }); } void setup(VisualStabilityManager visualStabilityManager) { mVisualStabilityManager = visualStabilityManager; } public void setAnimationStateHandler(AnimationStateHandler handler) { mAnimationStateHandler = handler; } Loading Loading @@ -333,14 +331,13 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, // We should not defer the removal if reordering isn't allowed since otherwise // these won't disappear until reordering is allowed again, which happens only once // the notification panel is collapsed again. return mVisualStabilityManager.isReorderingAllowed() && super.shouldExtendLifetime(entry); return mVisualStabilityProvider.isReorderingAllowed() && super.shouldExtendLifetime(entry); } /////////////////////////////////////////////////////////////////////////////////////////////// // VisualStabilityManager.Callback overrides: // OnReorderingAllowedListener: @Override public void onChangeAllowed() { private final OnReorderingAllowedListener mOnReorderingAllowedListener = () -> { mAnimationStateHandler.setHeadsUpGoingAwayAnimationsAllowed(false); for (NotificationEntry entry : mEntriesToRemoveWhenReorderingAllowed) { if (isAlerting(entry.getKey())) { Loading @@ -350,7 +347,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, } mEntriesToRemoveWhenReorderingAllowed.clear(); mAnimationStateHandler.setHeadsUpGoingAwayAnimationsAllowed(true); } }; /////////////////////////////////////////////////////////////////////////////////////////////// // HeadsUpManager utility (protected) methods overrides: Loading Loading @@ -431,13 +428,13 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, public void setEntry(@NonNull final NotificationEntry entry) { Runnable removeHeadsUpRunnable = () -> { if (!mVisualStabilityManager.isReorderingAllowed() if (!mVisualStabilityProvider.isReorderingAllowed() // We don't want to allow reordering while pulsing, but headsup need to // time out anyway && !entry.showingPulsing()) { mEntriesToRemoveWhenReorderingAllowed.add(entry); mVisualStabilityManager.addReorderingAllowedCallback(HeadsUpManagerPhone.this, false /* persistent */); mVisualStabilityProvider.addTemporaryReorderingAllowedListener( mOnReorderingAllowedListener); } else if (mTrackingHeadsUp) { mEntriesToRemoveAfterExpand.add(entry); } else { Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +3 −2 Original line number Diff line number Diff line Loading @@ -1185,10 +1185,11 @@ public class StatusBar extends CoreStartable implements }); initializer.initializeStatusBar(mStatusBarComponent); mHeadsUpManager.setup(mVisualStabilityManager); mStatusBarTouchableRegionManager.setup(this, mNotificationShadeWindowView); mHeadsUpManager.addListener(mNotificationPanelViewController.getOnHeadsUpChangedListener()); if (!mNotifPipelineFlags.isNewPipelineEnabled()) { mHeadsUpManager.addListener(mVisualStabilityManager); } mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager); createNavigationBar(result); Loading packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java +3 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.provider.VisualStabilityProvider; import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager; import com.android.systemui.statusbar.phone.DozeServiceHost; import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; Loading Loading @@ -167,6 +168,7 @@ public abstract class TvSystemUIModule { StatusBarStateController statusBarStateController, KeyguardBypassController bypassController, GroupMembershipManager groupManager, VisualStabilityProvider visualStabilityProvider, ConfigurationController configurationController) { return new HeadsUpManagerPhone( context, Loading @@ -174,6 +176,7 @@ public abstract class TvSystemUIModule { statusBarStateController, bypassController, groupManager, visualStabilityProvider, configurationController ); } Loading Loading
packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java +3 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.provider.VisualStabilityProvider; import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager; import com.android.systemui.statusbar.phone.DozeServiceHost; import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; Loading Loading @@ -174,6 +175,7 @@ public abstract class SystemUIDefaultModule { StatusBarStateController statusBarStateController, KeyguardBypassController bypassController, GroupMembershipManager groupManager, VisualStabilityProvider visualStabilityProvider, ConfigurationController configurationController) { return new HeadsUpManagerPhone( context, Loading @@ -181,6 +183,7 @@ public abstract class SystemUIDefaultModule { statusBarStateController, bypassController, groupManager, visualStabilityProvider, configurationController ); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/VisualStabilityProvider.kt +36 −4 Original line number Diff line number Diff line package com.android.systemui.statusbar.notification.collection.provider import android.util.ArraySet import com.android.systemui.dagger.SysUISingleton import com.android.systemui.util.ListenerSet import javax.inject.Inject @SysUISingleton class VisualStabilityProvider @Inject constructor() { private val listeners = ListenerSet<OnReorderingAllowedListener>() /** All persistent and temporary listeners, in the order they were added */ private val allListeners = ListenerSet<OnReorderingAllowedListener>() /** The subset of active listeners which are temporary (will be removed after called) */ private val temporaryListeners = ArraySet<OnReorderingAllowedListener>() var isReorderingAllowed = true set(value) { if (field != value) { field = value if (value) { listeners.forEach(OnReorderingAllowedListener::onReorderingAllowed) notifyReorderingAllowed() } } } private fun notifyReorderingAllowed() { allListeners.forEach { listener -> if (temporaryListeners.remove(listener)) { allListeners.remove(listener) } listener.onReorderingAllowed() } } fun addPersistentReorderingAllowedListener(listener: OnReorderingAllowedListener) = listeners.addIfAbsent(listener) /** Add a listener which will be called until it is explicitly removed. */ fun addPersistentReorderingAllowedListener(listener: OnReorderingAllowedListener) { temporaryListeners.remove(listener) allListeners.addIfAbsent(listener) } /** Add a listener which will be removed when it is called. */ fun addTemporaryReorderingAllowedListener(listener: OnReorderingAllowedListener) { // Only add to the temporary set if it was added to the global set // to keep permanent listeners permanent if (allListeners.addIfAbsent(listener)) { temporaryListeners.add(listener) } } /** Remove a listener from receiving any callbacks, whether it is persistent or temporary. */ fun removeReorderingAllowedListener(listener: OnReorderingAllowedListener) { temporaryListeners.remove(listener) allListeners.remove(listener) } } fun interface OnReorderingAllowedListener { Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java +13 −16 Original line number Diff line number Diff line Loading @@ -33,7 +33,8 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager; import com.android.systemui.statusbar.notification.collection.provider.OnReorderingAllowedListener; import com.android.systemui.statusbar.notification.collection.provider.VisualStabilityProvider; import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.policy.ConfigurationController; Loading @@ -52,7 +53,7 @@ import java.util.Stack; * A implementation of HeadsUpManager for phone and car. */ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, VisualStabilityManager.Callback, OnHeadsUpChangedListener { OnHeadsUpChangedListener { private static final String TAG = "HeadsUpManagerPhone"; @VisibleForTesting Loading @@ -60,8 +61,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, private final KeyguardBypassController mBypassController; private final GroupMembershipManager mGroupMembershipManager; private final List<OnHeadsUpPhoneListenerChange> mHeadsUpPhoneListeners = new ArrayList<>(); // TODO (b/162832756): remove visual stability manager when migrating to new pipeline private VisualStabilityManager mVisualStabilityManager; private final VisualStabilityProvider mVisualStabilityProvider; private boolean mReleaseOnExpandFinish; private boolean mTrackingHeadsUp; Loading Loading @@ -104,6 +104,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, StatusBarStateController statusBarStateController, KeyguardBypassController bypassController, GroupMembershipManager groupMembershipManager, VisualStabilityProvider visualStabilityProvider, ConfigurationController configurationController) { super(context, logger); Resources resources = mContext.getResources(); Loading @@ -111,6 +112,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, statusBarStateController.addCallback(mStatusBarStateListener); mBypassController = bypassController; mGroupMembershipManager = groupMembershipManager; mVisualStabilityProvider = visualStabilityProvider; updateResources(); configurationController.addCallback(new ConfigurationController.ConfigurationListener() { Loading @@ -126,10 +128,6 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, }); } void setup(VisualStabilityManager visualStabilityManager) { mVisualStabilityManager = visualStabilityManager; } public void setAnimationStateHandler(AnimationStateHandler handler) { mAnimationStateHandler = handler; } Loading Loading @@ -333,14 +331,13 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, // We should not defer the removal if reordering isn't allowed since otherwise // these won't disappear until reordering is allowed again, which happens only once // the notification panel is collapsed again. return mVisualStabilityManager.isReorderingAllowed() && super.shouldExtendLifetime(entry); return mVisualStabilityProvider.isReorderingAllowed() && super.shouldExtendLifetime(entry); } /////////////////////////////////////////////////////////////////////////////////////////////// // VisualStabilityManager.Callback overrides: // OnReorderingAllowedListener: @Override public void onChangeAllowed() { private final OnReorderingAllowedListener mOnReorderingAllowedListener = () -> { mAnimationStateHandler.setHeadsUpGoingAwayAnimationsAllowed(false); for (NotificationEntry entry : mEntriesToRemoveWhenReorderingAllowed) { if (isAlerting(entry.getKey())) { Loading @@ -350,7 +347,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, } mEntriesToRemoveWhenReorderingAllowed.clear(); mAnimationStateHandler.setHeadsUpGoingAwayAnimationsAllowed(true); } }; /////////////////////////////////////////////////////////////////////////////////////////////// // HeadsUpManager utility (protected) methods overrides: Loading Loading @@ -431,13 +428,13 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable, public void setEntry(@NonNull final NotificationEntry entry) { Runnable removeHeadsUpRunnable = () -> { if (!mVisualStabilityManager.isReorderingAllowed() if (!mVisualStabilityProvider.isReorderingAllowed() // We don't want to allow reordering while pulsing, but headsup need to // time out anyway && !entry.showingPulsing()) { mEntriesToRemoveWhenReorderingAllowed.add(entry); mVisualStabilityManager.addReorderingAllowedCallback(HeadsUpManagerPhone.this, false /* persistent */); mVisualStabilityProvider.addTemporaryReorderingAllowedListener( mOnReorderingAllowedListener); } else if (mTrackingHeadsUp) { mEntriesToRemoveAfterExpand.add(entry); } else { Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +3 −2 Original line number Diff line number Diff line Loading @@ -1185,10 +1185,11 @@ public class StatusBar extends CoreStartable implements }); initializer.initializeStatusBar(mStatusBarComponent); mHeadsUpManager.setup(mVisualStabilityManager); mStatusBarTouchableRegionManager.setup(this, mNotificationShadeWindowView); mHeadsUpManager.addListener(mNotificationPanelViewController.getOnHeadsUpChangedListener()); if (!mNotifPipelineFlags.isNewPipelineEnabled()) { mHeadsUpManager.addListener(mVisualStabilityManager); } mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager); createNavigationBar(result); Loading
packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java +3 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.collection.provider.VisualStabilityProvider; import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager; import com.android.systemui.statusbar.phone.DozeServiceHost; import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; Loading Loading @@ -167,6 +168,7 @@ public abstract class TvSystemUIModule { StatusBarStateController statusBarStateController, KeyguardBypassController bypassController, GroupMembershipManager groupManager, VisualStabilityProvider visualStabilityProvider, ConfigurationController configurationController) { return new HeadsUpManagerPhone( context, Loading @@ -174,6 +176,7 @@ public abstract class TvSystemUIModule { statusBarStateController, bypassController, groupManager, visualStabilityProvider, configurationController ); } Loading