Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java +20 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,18 @@ public interface NotificationLockscreenUserManager { */ boolean userAllowsNotificationsInPublic(int userId); /** * Adds a {@link NotificationStateChangedListener} to be notified of any state changes that * would affect presentation of notifications. */ void addNotificationStateChangedListener(NotificationStateChangedListener listener); /** * Removes a {@link NotificationStateChangedListener} that was previously registered with * {@link #addNotificationStateChangedListener(NotificationStateChangedListener)}. */ void removeNotificationStateChangedListener(NotificationStateChangedListener listener); /** Notified when the current user changes. */ interface UserChangedListener { default void onUserChanged(int userId) {} Loading @@ -100,4 +112,12 @@ public interface NotificationLockscreenUserManager { interface KeyguardNotificationSuppressor { boolean shouldSuppressOnKeyguard(NotificationEntry entry); } /** * Notified when any state pertaining to Notifications has changed; any methods pertaining to * notifications should be re-queried. */ interface NotificationStateChangedListener { void onNotificationStateChanged(); } } packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java +26 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.Co import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.ListenerSet; import com.android.systemui.util.settings.SecureSettings; import java.io.PrintWriter; Loading Loading @@ -110,6 +111,8 @@ public class NotificationLockscreenUserManagerImpl implements protected KeyguardManager mKeyguardManager; private int mState = StatusBarState.SHADE; private List<KeyguardNotificationSuppressor> mKeyguardSuppressors = new ArrayList<>(); private final ListenerSet<NotificationStateChangedListener> mNotifStateChangedListeners = new ListenerSet<>(); protected final BroadcastReceiver mAllUsersReceiver = new BroadcastReceiver() { @Override Loading @@ -121,6 +124,8 @@ public class NotificationLockscreenUserManagerImpl implements mUsersAllowingPrivateNotifications.clear(); updateLockscreenNotificationSetting(); getEntryManager().updateNotifications("ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED"); // TODO(b/231976036): Consolidate pipeline invalidations related to this event // notifyNotificationStateChanged(); } } }; Loading Loading @@ -254,6 +259,7 @@ public class NotificationLockscreenUserManagerImpl implements updateLockscreenNotificationSetting(); getEntryManager().updateNotifications("LOCK_SCREEN_SHOW_NOTIFICATIONS," + " or LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS change"); notifyNotificationStateChanged(); } }; Loading @@ -264,6 +270,8 @@ public class NotificationLockscreenUserManagerImpl implements if (mDeviceProvisionedController.isDeviceProvisioned()) { getEntryManager().updateNotifications("LOCK_SCREEN_ALLOW_REMOTE_INPUT" + " or ZEN_MODE change"); // TODO(b/231976036): Consolidate pipeline invalidations related to this event // notifyNotificationStateChanged(); } } }; Loading Loading @@ -651,6 +659,8 @@ public class NotificationLockscreenUserManagerImpl implements mUsersWithSeparateWorkChallenge.put(userId, needsSeparateChallenge); } getEntryManager().updateNotifications("NotificationLockscreenUserManager.updatePublicMode"); // TODO(b/234738798): Migrate KeyguardNotificationVisibilityProvider to use this listener // notifyNotificationStateChanged(); } @Override Loading @@ -668,6 +678,22 @@ public class NotificationLockscreenUserManagerImpl implements mListeners.remove(listener); } @Override public void addNotificationStateChangedListener(NotificationStateChangedListener listener) { mNotifStateChangedListeners.addIfAbsent(listener); } @Override public void removeNotificationStateChangedListener(NotificationStateChangedListener listener) { mNotifStateChangedListeners.remove(listener); } private void notifyNotificationStateChanged() { for (NotificationStateChangedListener listener : mNotifStateChangedListeners) { listener.onNotificationStateChanged(); } } // public void updatePublicMode() { // //TODO: I think there may be a race condition where mKeyguardViewManager.isShowing() returns // // false when it should be true. Therefore, if we are not on the SHADE, don't even bother Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinator.java +1 −0 Original line number Diff line number Diff line Loading @@ -147,6 +147,7 @@ public class PreparationCoordinator implements Coordinator { @Override public void attach(NotifPipeline pipeline) { mNotifErrorManager.addInflationErrorListener(mInflationErrorListener); mAdjustmentProvider.addDirtyListener(mNotifInflatingFilter::invalidateList); pipeline.addCollectionListener(mNotifCollectionListener); // Inflate after grouping/sorting since that affects what views to inflate. Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustment.kt +3 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,8 @@ class NotifUiAdjustment internal constructor( val smartActions: List<Notification.Action>, val smartReplies: List<CharSequence>, val isConversation: Boolean, val isMinimized: Boolean val isMinimized: Boolean, val needsRedaction: Boolean, ) { companion object { @JvmStatic Loading @@ -42,6 +43,7 @@ class NotifUiAdjustment internal constructor( oldAdjustment === newAdjustment -> false oldAdjustment.isConversation != newAdjustment.isConversation -> true oldAdjustment.isMinimized != newAdjustment.isMinimized -> true oldAdjustment.needsRedaction != newAdjustment.needsRedaction -> true areDifferent(oldAdjustment.smartActions, newAdjustment.smartActions) -> true newAdjustment.smartReplies != oldAdjustment.smartReplies -> true else -> false Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt +29 −5 Original line number Diff line number Diff line Loading @@ -17,9 +17,11 @@ package com.android.systemui.statusbar.notification.collection.inflation import com.android.systemui.dagger.SysUISingleton import com.android.systemui.statusbar.NotificationLockscreenUserManager import com.android.systemui.statusbar.notification.SectionClassifier import com.android.systemui.statusbar.notification.collection.GroupEntry import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.util.ListenerSet import javax.inject.Inject /** Loading @@ -27,9 +29,30 @@ import javax.inject.Inject * to ensure that notifications are reinflated when ranking-derived information changes. */ @SysUISingleton open class NotifUiAdjustmentProvider @Inject constructor( private val sectionClassifier: SectionClassifier class NotifUiAdjustmentProvider @Inject constructor( private val lockscreenUserManager: NotificationLockscreenUserManager, private val sectionClassifier: SectionClassifier, ) { private val dirtyListeners = ListenerSet<Runnable>() fun addDirtyListener(listener: Runnable) { if (dirtyListeners.isEmpty()) { lockscreenUserManager.addNotificationStateChangedListener(notifStateChangedListener) } dirtyListeners.addIfAbsent(listener) } fun removeDirtyListener(listener: Runnable) { dirtyListeners.remove(listener) if (dirtyListeners.isEmpty()) { lockscreenUserManager.removeNotificationStateChangedListener(notifStateChangedListener) } } private val notifStateChangedListener = NotificationLockscreenUserManager.NotificationStateChangedListener { dirtyListeners.forEach(Runnable::run) } private fun isEntryMinimized(entry: NotificationEntry): Boolean { val section = entry.section ?: error("Entry must have a section to determine if minimized") Loading @@ -42,14 +65,15 @@ open class NotifUiAdjustmentProvider @Inject constructor( /** * Returns a adjustment object for the given entry. This can be compared to a previous instance * from the same notification using [NotifUiAdjustment.needReinflate] to determine if it * should be reinflated. * from the same notification using [NotifUiAdjustment.needReinflate] to determine if it should * be reinflated. */ fun calculateAdjustment(entry: NotificationEntry) = NotifUiAdjustment( key = entry.key, smartActions = entry.ranking.smartActions, smartReplies = entry.ranking.smartReplies, isConversation = entry.ranking.isConversation, isMinimized = isEntryMinimized(entry) isMinimized = isEntryMinimized(entry), needsRedaction = lockscreenUserManager.needsRedaction(entry), ) } No newline at end of file Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java +20 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,18 @@ public interface NotificationLockscreenUserManager { */ boolean userAllowsNotificationsInPublic(int userId); /** * Adds a {@link NotificationStateChangedListener} to be notified of any state changes that * would affect presentation of notifications. */ void addNotificationStateChangedListener(NotificationStateChangedListener listener); /** * Removes a {@link NotificationStateChangedListener} that was previously registered with * {@link #addNotificationStateChangedListener(NotificationStateChangedListener)}. */ void removeNotificationStateChangedListener(NotificationStateChangedListener listener); /** Notified when the current user changes. */ interface UserChangedListener { default void onUserChanged(int userId) {} Loading @@ -100,4 +112,12 @@ public interface NotificationLockscreenUserManager { interface KeyguardNotificationSuppressor { boolean shouldSuppressOnKeyguard(NotificationEntry entry); } /** * Notified when any state pertaining to Notifications has changed; any methods pertaining to * notifications should be re-queried. */ interface NotificationStateChangedListener { void onNotificationStateChanged(); } }
packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java +26 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.Co import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.ListenerSet; import com.android.systemui.util.settings.SecureSettings; import java.io.PrintWriter; Loading Loading @@ -110,6 +111,8 @@ public class NotificationLockscreenUserManagerImpl implements protected KeyguardManager mKeyguardManager; private int mState = StatusBarState.SHADE; private List<KeyguardNotificationSuppressor> mKeyguardSuppressors = new ArrayList<>(); private final ListenerSet<NotificationStateChangedListener> mNotifStateChangedListeners = new ListenerSet<>(); protected final BroadcastReceiver mAllUsersReceiver = new BroadcastReceiver() { @Override Loading @@ -121,6 +124,8 @@ public class NotificationLockscreenUserManagerImpl implements mUsersAllowingPrivateNotifications.clear(); updateLockscreenNotificationSetting(); getEntryManager().updateNotifications("ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED"); // TODO(b/231976036): Consolidate pipeline invalidations related to this event // notifyNotificationStateChanged(); } } }; Loading Loading @@ -254,6 +259,7 @@ public class NotificationLockscreenUserManagerImpl implements updateLockscreenNotificationSetting(); getEntryManager().updateNotifications("LOCK_SCREEN_SHOW_NOTIFICATIONS," + " or LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS change"); notifyNotificationStateChanged(); } }; Loading @@ -264,6 +270,8 @@ public class NotificationLockscreenUserManagerImpl implements if (mDeviceProvisionedController.isDeviceProvisioned()) { getEntryManager().updateNotifications("LOCK_SCREEN_ALLOW_REMOTE_INPUT" + " or ZEN_MODE change"); // TODO(b/231976036): Consolidate pipeline invalidations related to this event // notifyNotificationStateChanged(); } } }; Loading Loading @@ -651,6 +659,8 @@ public class NotificationLockscreenUserManagerImpl implements mUsersWithSeparateWorkChallenge.put(userId, needsSeparateChallenge); } getEntryManager().updateNotifications("NotificationLockscreenUserManager.updatePublicMode"); // TODO(b/234738798): Migrate KeyguardNotificationVisibilityProvider to use this listener // notifyNotificationStateChanged(); } @Override Loading @@ -668,6 +678,22 @@ public class NotificationLockscreenUserManagerImpl implements mListeners.remove(listener); } @Override public void addNotificationStateChangedListener(NotificationStateChangedListener listener) { mNotifStateChangedListeners.addIfAbsent(listener); } @Override public void removeNotificationStateChangedListener(NotificationStateChangedListener listener) { mNotifStateChangedListeners.remove(listener); } private void notifyNotificationStateChanged() { for (NotificationStateChangedListener listener : mNotifStateChangedListeners) { listener.onNotificationStateChanged(); } } // public void updatePublicMode() { // //TODO: I think there may be a race condition where mKeyguardViewManager.isShowing() returns // // false when it should be true. Therefore, if we are not on the SHADE, don't even bother Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/PreparationCoordinator.java +1 −0 Original line number Diff line number Diff line Loading @@ -147,6 +147,7 @@ public class PreparationCoordinator implements Coordinator { @Override public void attach(NotifPipeline pipeline) { mNotifErrorManager.addInflationErrorListener(mInflationErrorListener); mAdjustmentProvider.addDirtyListener(mNotifInflatingFilter::invalidateList); pipeline.addCollectionListener(mNotifCollectionListener); // Inflate after grouping/sorting since that affects what views to inflate. Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustment.kt +3 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,8 @@ class NotifUiAdjustment internal constructor( val smartActions: List<Notification.Action>, val smartReplies: List<CharSequence>, val isConversation: Boolean, val isMinimized: Boolean val isMinimized: Boolean, val needsRedaction: Boolean, ) { companion object { @JvmStatic Loading @@ -42,6 +43,7 @@ class NotifUiAdjustment internal constructor( oldAdjustment === newAdjustment -> false oldAdjustment.isConversation != newAdjustment.isConversation -> true oldAdjustment.isMinimized != newAdjustment.isMinimized -> true oldAdjustment.needsRedaction != newAdjustment.needsRedaction -> true areDifferent(oldAdjustment.smartActions, newAdjustment.smartActions) -> true newAdjustment.smartReplies != oldAdjustment.smartReplies -> true else -> false Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotifUiAdjustmentProvider.kt +29 −5 Original line number Diff line number Diff line Loading @@ -17,9 +17,11 @@ package com.android.systemui.statusbar.notification.collection.inflation import com.android.systemui.dagger.SysUISingleton import com.android.systemui.statusbar.NotificationLockscreenUserManager import com.android.systemui.statusbar.notification.SectionClassifier import com.android.systemui.statusbar.notification.collection.GroupEntry import com.android.systemui.statusbar.notification.collection.NotificationEntry import com.android.systemui.util.ListenerSet import javax.inject.Inject /** Loading @@ -27,9 +29,30 @@ import javax.inject.Inject * to ensure that notifications are reinflated when ranking-derived information changes. */ @SysUISingleton open class NotifUiAdjustmentProvider @Inject constructor( private val sectionClassifier: SectionClassifier class NotifUiAdjustmentProvider @Inject constructor( private val lockscreenUserManager: NotificationLockscreenUserManager, private val sectionClassifier: SectionClassifier, ) { private val dirtyListeners = ListenerSet<Runnable>() fun addDirtyListener(listener: Runnable) { if (dirtyListeners.isEmpty()) { lockscreenUserManager.addNotificationStateChangedListener(notifStateChangedListener) } dirtyListeners.addIfAbsent(listener) } fun removeDirtyListener(listener: Runnable) { dirtyListeners.remove(listener) if (dirtyListeners.isEmpty()) { lockscreenUserManager.removeNotificationStateChangedListener(notifStateChangedListener) } } private val notifStateChangedListener = NotificationLockscreenUserManager.NotificationStateChangedListener { dirtyListeners.forEach(Runnable::run) } private fun isEntryMinimized(entry: NotificationEntry): Boolean { val section = entry.section ?: error("Entry must have a section to determine if minimized") Loading @@ -42,14 +65,15 @@ open class NotifUiAdjustmentProvider @Inject constructor( /** * Returns a adjustment object for the given entry. This can be compared to a previous instance * from the same notification using [NotifUiAdjustment.needReinflate] to determine if it * should be reinflated. * from the same notification using [NotifUiAdjustment.needReinflate] to determine if it should * be reinflated. */ fun calculateAdjustment(entry: NotificationEntry) = NotifUiAdjustment( key = entry.key, smartActions = entry.ranking.smartActions, smartReplies = entry.ranking.smartReplies, isConversation = entry.ranking.isConversation, isMinimized = isEntryMinimized(entry) isMinimized = isEntryMinimized(entry), needsRedaction = lockscreenUserManager.needsRedaction(entry), ) } No newline at end of file