Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -689,8 +689,9 @@ public class NotificationEntryManager implements for (NotificationEntryListener listener : mNotificationEntryListeners) { listener.onPreEntryUpdated(entry); } final boolean fromSystem = ranking != null; for (NotifCollectionListener listener : mNotifCollectionListeners) { listener.onEntryUpdated(entry); listener.onEntryUpdated(entry, fromSystem); } if (!mFeatureFlags.isNewNotifPipelineRenderingEnabled()) { Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java +52 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.annotation.MainThread; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.app.Notification; import android.os.Handler; import android.os.RemoteException; import android.os.UserHandle; import android.service.notification.NotificationListenerService; Loading @@ -61,6 +62,7 @@ import androidx.annotation.NonNull; import com.android.internal.statusbar.IStatusBarService; import com.android.systemui.Dumpable; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; import com.android.systemui.dump.LogBufferEulogizer; import com.android.systemui.flags.FeatureFlags; Loading @@ -75,6 +77,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.En import com.android.systemui.statusbar.notification.collection.notifcollection.EntryRemovedEvent; import com.android.systemui.statusbar.notification.collection.notifcollection.EntryUpdatedEvent; import com.android.systemui.statusbar.notification.collection.notifcollection.InitEntryEvent; import com.android.systemui.statusbar.notification.collection.notifcollection.InternalNotifUpdater; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionLogger; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifDismissInterceptor; Loading Loading @@ -130,6 +133,7 @@ public class NotifCollection implements Dumpable { private final SystemClock mClock; private final FeatureFlags mFeatureFlags; private final NotifCollectionLogger mLogger; private final Handler mMainHandler; private final LogBufferEulogizer mEulogizer; private final Map<String, NotificationEntry> mNotificationSet = new ArrayMap<>(); Loading @@ -153,6 +157,7 @@ public class NotifCollection implements Dumpable { SystemClock clock, FeatureFlags featureFlags, NotifCollectionLogger logger, @Main Handler mainHandler, LogBufferEulogizer logBufferEulogizer, DumpManager dumpManager) { Assert.isMainThread(); Loading @@ -160,6 +165,7 @@ public class NotifCollection implements Dumpable { mClock = clock; mFeatureFlags = featureFlags; mLogger = logger; mMainHandler = mainHandler; mEulogizer = logBufferEulogizer; dumpManager.registerDumpable(TAG, this); Loading Loading @@ -441,7 +447,7 @@ public class NotifCollection implements Dumpable { mEventQueue.add(new BindEntryEvent(entry, sbn)); mLogger.logNotifUpdated(sbn.getKey()); mEventQueue.add(new EntryUpdatedEvent(entry)); mEventQueue.add(new EntryUpdatedEvent(entry, true /* fromSystem */)); } } Loading Loading @@ -788,6 +794,51 @@ public class NotifCollection implements Dumpable { private static final String TAG = "NotifCollection"; /** * Get an object which can be used to update a notification (internally to the pipeline) * in response to a user action. * * @param name the name of the component that will update notifiations * @return an updater */ public InternalNotifUpdater getInternalNotifUpdater(String name) { return (sbn, reason) -> mMainHandler.post( () -> updateNotificationInternally(sbn, name, reason)); } /** * Provide an updated StatusBarNotification for an existing entry. If no entry exists for the * given notification key, this method does nothing. * * @param sbn the updated notification * @param name the component which is updating the notification * @param reason the reason the notification is being updated */ private void updateNotificationInternally(StatusBarNotification sbn, String name, String reason) { Assert.isMainThread(); checkForReentrantCall(); // Make sure we have the notification to update NotificationEntry entry = mNotificationSet.get(sbn.getKey()); if (entry == null) { mLogger.logNotifInternalUpdateFailed(sbn.getKey(), name, reason); return; } mLogger.logNotifInternalUpdate(sbn.getKey(), name, reason); // First do the pieces of postNotification which are not about assuming the notification // was sent by the app entry.setSbn(sbn); mEventQueue.add(new BindEntryEvent(entry, sbn)); mLogger.logNotifUpdated(sbn.getKey()); mEventQueue.add(new EntryUpdatedEvent(entry, false /* fromSystem */)); // Skip the applyRanking step and go straight to dispatching the events dispatchEventsAndRebuildList(); } @IntDef(prefix = { "REASON_" }, value = { REASON_NOT_CANCELED, REASON_UNKNOWN, Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifPipeline.java +14 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification.collection; import android.os.Handler; import androidx.annotation.Nullable; import com.android.systemui.dagger.SysUISingleton; Loading @@ -30,6 +32,7 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.plugga import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifStabilityManager; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.statusbar.notification.collection.notifcollection.InternalNotifUpdater; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifDismissInterceptor; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifLifetimeExtender; Loading Loading @@ -222,6 +225,17 @@ public class NotifPipeline implements CommonNotifCollection { mShadeListBuilder.addPreRenderInvalidator(invalidator); } /** * Get an object which can be used to update a notification (internally to the pipeline) * in response to a user action. * * @param name the name of the component that will update notifiations * @return an updater */ public InternalNotifUpdater getInternalNotifUpdater(String name) { return mNotifCollection.getInternalNotifUpdater(name); } /** * Returns a read-only view in to the current shade list, i.e. the list of notifications that * are currently present in the shade. If this method is called during pipeline execution it Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/notifcollection/InternalNotifUpdater.java 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.notification.collection.notifcollection; import android.service.notification.StatusBarNotification; /** * An object that allows Coordinators to update notifications internally to SystemUI. * This is used when part of the UI involves updating the underlying appearance of a notification * on behalf of an app, such as to add a spinner or remote input history. */ public interface InternalNotifUpdater { /** * Called when an already-existing notification needs to be updated to a new temporary * appearance. * This update is local to the SystemUI process. * This has no effect if no notification with the given key exists in the pipeline. * * @param sbn a notification to update * @param reason a debug reason for the update */ void onInternalNotificationUpdate(StatusBarNotification sbn, String reason); } packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/notifcollection/NotifCollectionListener.java +11 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,17 @@ public interface NotifCollectionListener { default void onEntryAdded(@NonNull NotificationEntry entry) { } /** * Called whenever a notification with the same key as an existing notification is posted. By * the time this listener is called, the entry's SBN and Ranking will already have been updated. * This delegates to {@link #onEntryUpdated(NotificationEntry)} by default. * @param fromSystem If true, this update came from the NotificationManagerService. * If false, the notification update is an internal change within systemui. */ default void onEntryUpdated(@NonNull NotificationEntry entry, boolean fromSystem) { onEntryUpdated(entry); } /** * Called whenever a notification with the same key as an existing notification is posted. By * the time this listener is called, the entry's SBN and Ranking will already have been updated. Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -689,8 +689,9 @@ public class NotificationEntryManager implements for (NotificationEntryListener listener : mNotificationEntryListeners) { listener.onPreEntryUpdated(entry); } final boolean fromSystem = ranking != null; for (NotifCollectionListener listener : mNotifCollectionListeners) { listener.onEntryUpdated(entry); listener.onEntryUpdated(entry, fromSystem); } if (!mFeatureFlags.isNewNotifPipelineRenderingEnabled()) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java +52 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.annotation.MainThread; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.app.Notification; import android.os.Handler; import android.os.RemoteException; import android.os.UserHandle; import android.service.notification.NotificationListenerService; Loading @@ -61,6 +62,7 @@ import androidx.annotation.NonNull; import com.android.internal.statusbar.IStatusBarService; import com.android.systemui.Dumpable; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; import com.android.systemui.dump.LogBufferEulogizer; import com.android.systemui.flags.FeatureFlags; Loading @@ -75,6 +77,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.En import com.android.systemui.statusbar.notification.collection.notifcollection.EntryRemovedEvent; import com.android.systemui.statusbar.notification.collection.notifcollection.EntryUpdatedEvent; import com.android.systemui.statusbar.notification.collection.notifcollection.InitEntryEvent; import com.android.systemui.statusbar.notification.collection.notifcollection.InternalNotifUpdater; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionLogger; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifDismissInterceptor; Loading Loading @@ -130,6 +133,7 @@ public class NotifCollection implements Dumpable { private final SystemClock mClock; private final FeatureFlags mFeatureFlags; private final NotifCollectionLogger mLogger; private final Handler mMainHandler; private final LogBufferEulogizer mEulogizer; private final Map<String, NotificationEntry> mNotificationSet = new ArrayMap<>(); Loading @@ -153,6 +157,7 @@ public class NotifCollection implements Dumpable { SystemClock clock, FeatureFlags featureFlags, NotifCollectionLogger logger, @Main Handler mainHandler, LogBufferEulogizer logBufferEulogizer, DumpManager dumpManager) { Assert.isMainThread(); Loading @@ -160,6 +165,7 @@ public class NotifCollection implements Dumpable { mClock = clock; mFeatureFlags = featureFlags; mLogger = logger; mMainHandler = mainHandler; mEulogizer = logBufferEulogizer; dumpManager.registerDumpable(TAG, this); Loading Loading @@ -441,7 +447,7 @@ public class NotifCollection implements Dumpable { mEventQueue.add(new BindEntryEvent(entry, sbn)); mLogger.logNotifUpdated(sbn.getKey()); mEventQueue.add(new EntryUpdatedEvent(entry)); mEventQueue.add(new EntryUpdatedEvent(entry, true /* fromSystem */)); } } Loading Loading @@ -788,6 +794,51 @@ public class NotifCollection implements Dumpable { private static final String TAG = "NotifCollection"; /** * Get an object which can be used to update a notification (internally to the pipeline) * in response to a user action. * * @param name the name of the component that will update notifiations * @return an updater */ public InternalNotifUpdater getInternalNotifUpdater(String name) { return (sbn, reason) -> mMainHandler.post( () -> updateNotificationInternally(sbn, name, reason)); } /** * Provide an updated StatusBarNotification for an existing entry. If no entry exists for the * given notification key, this method does nothing. * * @param sbn the updated notification * @param name the component which is updating the notification * @param reason the reason the notification is being updated */ private void updateNotificationInternally(StatusBarNotification sbn, String name, String reason) { Assert.isMainThread(); checkForReentrantCall(); // Make sure we have the notification to update NotificationEntry entry = mNotificationSet.get(sbn.getKey()); if (entry == null) { mLogger.logNotifInternalUpdateFailed(sbn.getKey(), name, reason); return; } mLogger.logNotifInternalUpdate(sbn.getKey(), name, reason); // First do the pieces of postNotification which are not about assuming the notification // was sent by the app entry.setSbn(sbn); mEventQueue.add(new BindEntryEvent(entry, sbn)); mLogger.logNotifUpdated(sbn.getKey()); mEventQueue.add(new EntryUpdatedEvent(entry, false /* fromSystem */)); // Skip the applyRanking step and go straight to dispatching the events dispatchEventsAndRebuildList(); } @IntDef(prefix = { "REASON_" }, value = { REASON_NOT_CANCELED, REASON_UNKNOWN, Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifPipeline.java +14 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification.collection; import android.os.Handler; import androidx.annotation.Nullable; import com.android.systemui.dagger.SysUISingleton; Loading @@ -30,6 +32,7 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.plugga import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner; import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifStabilityManager; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; import com.android.systemui.statusbar.notification.collection.notifcollection.InternalNotifUpdater; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifDismissInterceptor; import com.android.systemui.statusbar.notification.collection.notifcollection.NotifLifetimeExtender; Loading Loading @@ -222,6 +225,17 @@ public class NotifPipeline implements CommonNotifCollection { mShadeListBuilder.addPreRenderInvalidator(invalidator); } /** * Get an object which can be used to update a notification (internally to the pipeline) * in response to a user action. * * @param name the name of the component that will update notifiations * @return an updater */ public InternalNotifUpdater getInternalNotifUpdater(String name) { return mNotifCollection.getInternalNotifUpdater(name); } /** * Returns a read-only view in to the current shade list, i.e. the list of notifications that * are currently present in the shade. If this method is called during pipeline execution it Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/notifcollection/InternalNotifUpdater.java 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.statusbar.notification.collection.notifcollection; import android.service.notification.StatusBarNotification; /** * An object that allows Coordinators to update notifications internally to SystemUI. * This is used when part of the UI involves updating the underlying appearance of a notification * on behalf of an app, such as to add a spinner or remote input history. */ public interface InternalNotifUpdater { /** * Called when an already-existing notification needs to be updated to a new temporary * appearance. * This update is local to the SystemUI process. * This has no effect if no notification with the given key exists in the pipeline. * * @param sbn a notification to update * @param reason a debug reason for the update */ void onInternalNotificationUpdate(StatusBarNotification sbn, String reason); }
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/notifcollection/NotifCollectionListener.java +11 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,17 @@ public interface NotifCollectionListener { default void onEntryAdded(@NonNull NotificationEntry entry) { } /** * Called whenever a notification with the same key as an existing notification is posted. By * the time this listener is called, the entry's SBN and Ranking will already have been updated. * This delegates to {@link #onEntryUpdated(NotificationEntry)} by default. * @param fromSystem If true, this update came from the NotificationManagerService. * If false, the notification update is an internal change within systemui. */ default void onEntryUpdated(@NonNull NotificationEntry entry, boolean fromSystem) { onEntryUpdated(entry); } /** * Called whenever a notification with the same key as an existing notification is posted. By * the time this listener is called, the entry's SBN and Ranking will already have been updated. Loading