Loading core/java/android/app/ActivityManagerInternal.java +4 −4 Original line number Diff line number Diff line Loading @@ -486,11 +486,11 @@ public abstract class ActivityManagerInternal { /** * Callback from the notification subsystem that the given FGS notification has * been shown or updated. This can happen after either Service.startForeground() * or NotificationManager.notify(). * been evaluated, and either shown or explicitly overlooked. This can happen * after either Service.startForeground() or NotificationManager.notify(). */ public abstract void onForegroundServiceNotificationUpdate(Notification notification, int id, String pkg, @UserIdInt int userId); public abstract void onForegroundServiceNotificationUpdate(boolean shown, Notification notification, int id, String pkg, @UserIdInt int userId); /** * If the given app has any FGSs whose notifications are in the given channel, Loading services/core/java/com/android/server/am/ActiveServices.java +20 −10 Original line number Diff line number Diff line Loading @@ -2221,8 +2221,9 @@ public final class ActiveServices { * visibility, starting with both Service.startForeground() and * NotificationManager.notify(). */ public void onForegroundServiceNotificationUpdateLocked(Notification notification, final int id, final String pkg, @UserIdInt final int userId) { public void onForegroundServiceNotificationUpdateLocked(boolean shown, Notification notification, final int id, final String pkg, @UserIdInt final int userId) { // If this happens to be a Notification for an FGS still in its deferral period, // drop the deferral and make sure our content bookkeeping is up to date. for (int i = mPendingFgsNotifications.size() - 1; i >= 0; i--) { Loading @@ -2230,17 +2231,26 @@ public final class ActiveServices { if (userId == sr.userId && id == sr.foregroundId && sr.appInfo.packageName.equals(pkg)) { // Found it. If 'shown' is false, it means that the notification // subsystem will not be displaying it yet, so all we do is log // the "fgs entered" transition noting deferral, then we're done. maybeLogFGSStateEnteredLocked(sr); if (shown) { if (DEBUG_FOREGROUND_SERVICE) { Slog.d(TAG_SERVICE, "Notification shown; canceling deferral of " + sr); } maybeLogFGSStateEnteredLocked(sr); sr.mFgsNotificationShown = true; sr.mFgsNotificationDeferred = false; mPendingFgsNotifications.remove(i); } else { if (DEBUG_FOREGROUND_SERVICE) { Slog.d(TAG_SERVICE, "FGS notification deferred for " + sr); } } } } // And make sure to retain the latest notification content for the FGS // In all cases, make sure to retain the latest notification content for the FGS ServiceMap smap = mServiceMap.get(userId); if (smap != null) { for (int i = 0; i < smap.mServicesByInstanceName.size(); i++) { Loading services/core/java/com/android/server/am/ActivityManagerService.java +4 −6 Original line number Diff line number Diff line Loading @@ -350,8 +350,6 @@ import com.android.internal.util.Preconditions; import com.android.internal.util.function.DecFunction; import com.android.internal.util.function.HeptFunction; import com.android.internal.util.function.HexFunction; import com.android.internal.util.function.NonaFunction; import com.android.internal.util.function.OctFunction; import com.android.internal.util.function.QuadFunction; import com.android.internal.util.function.QuintFunction; import com.android.internal.util.function.TriFunction; Loading Loading @@ -16085,11 +16083,11 @@ public class ActivityManagerService extends IActivityManager.Stub } @Override public void onForegroundServiceNotificationUpdate(Notification notification, int id, String pkg, @UserIdInt int userId) { public void onForegroundServiceNotificationUpdate(boolean shown, Notification notification, int id, String pkg, @UserIdInt int userId) { synchronized (ActivityManagerService.this) { mServices.onForegroundServiceNotificationUpdateLocked(notification, id, pkg, userId); mServices.onForegroundServiceNotificationUpdateLocked(shown, notification, id, pkg, userId); } } services/core/java/com/android/server/notification/NotificationManagerService.java +12 −9 Original line number Diff line number Diff line Loading @@ -3052,17 +3052,19 @@ public class NotificationManagerService extends SystemService { } } protected void maybeReportForegroundServiceUpdate(final NotificationRecord r) { protected void reportForegroundServiceUpdate(boolean shown, final Notification notification, final int id, final String pkg, final int userId) { mHandler.post(() -> { mAmi.onForegroundServiceNotificationUpdate(shown, notification, id, pkg, userId); }); } protected void maybeReportForegroundServiceUpdate(final NotificationRecord r, boolean shown) { if (r.isForegroundService()) { // snapshot live state for the asynchronous operation final StatusBarNotification sbn = r.getSbn(); final Notification notification = sbn.getNotification(); final int id = sbn.getId(); final String pkg = sbn.getPackageName(); final int userId = sbn.getUser().getIdentifier(); mHandler.post(() -> { mAmi.onForegroundServiceNotificationUpdate(notification, id, pkg, userId); }); reportForegroundServiceUpdate(shown, sbn.getNotification(), sbn.getId(), sbn.getPackageName(), sbn.getUser().getIdentifier()); } } Loading Loading @@ -6194,6 +6196,7 @@ public class NotificationManagerService extends SystemService { // because the service lifecycle logic has retained responsibility for its // handling. if (!isNotificationShownInternal(pkg, tag, id, userId)) { reportForegroundServiceUpdate(false, notification, id, pkg, userId); return; } } Loading Loading @@ -7121,7 +7124,7 @@ public class NotificationManagerService extends SystemService { maybeRecordInterruptionLocked(r); maybeRegisterMessageSent(r); maybeReportForegroundServiceUpdate(r); maybeReportForegroundServiceUpdate(r, true); // Log event to statsd mNotificationRecordLogger.maybeLogNotificationPosted(r, old, position, Loading Loading
core/java/android/app/ActivityManagerInternal.java +4 −4 Original line number Diff line number Diff line Loading @@ -486,11 +486,11 @@ public abstract class ActivityManagerInternal { /** * Callback from the notification subsystem that the given FGS notification has * been shown or updated. This can happen after either Service.startForeground() * or NotificationManager.notify(). * been evaluated, and either shown or explicitly overlooked. This can happen * after either Service.startForeground() or NotificationManager.notify(). */ public abstract void onForegroundServiceNotificationUpdate(Notification notification, int id, String pkg, @UserIdInt int userId); public abstract void onForegroundServiceNotificationUpdate(boolean shown, Notification notification, int id, String pkg, @UserIdInt int userId); /** * If the given app has any FGSs whose notifications are in the given channel, Loading
services/core/java/com/android/server/am/ActiveServices.java +20 −10 Original line number Diff line number Diff line Loading @@ -2221,8 +2221,9 @@ public final class ActiveServices { * visibility, starting with both Service.startForeground() and * NotificationManager.notify(). */ public void onForegroundServiceNotificationUpdateLocked(Notification notification, final int id, final String pkg, @UserIdInt final int userId) { public void onForegroundServiceNotificationUpdateLocked(boolean shown, Notification notification, final int id, final String pkg, @UserIdInt final int userId) { // If this happens to be a Notification for an FGS still in its deferral period, // drop the deferral and make sure our content bookkeeping is up to date. for (int i = mPendingFgsNotifications.size() - 1; i >= 0; i--) { Loading @@ -2230,17 +2231,26 @@ public final class ActiveServices { if (userId == sr.userId && id == sr.foregroundId && sr.appInfo.packageName.equals(pkg)) { // Found it. If 'shown' is false, it means that the notification // subsystem will not be displaying it yet, so all we do is log // the "fgs entered" transition noting deferral, then we're done. maybeLogFGSStateEnteredLocked(sr); if (shown) { if (DEBUG_FOREGROUND_SERVICE) { Slog.d(TAG_SERVICE, "Notification shown; canceling deferral of " + sr); } maybeLogFGSStateEnteredLocked(sr); sr.mFgsNotificationShown = true; sr.mFgsNotificationDeferred = false; mPendingFgsNotifications.remove(i); } else { if (DEBUG_FOREGROUND_SERVICE) { Slog.d(TAG_SERVICE, "FGS notification deferred for " + sr); } } } } // And make sure to retain the latest notification content for the FGS // In all cases, make sure to retain the latest notification content for the FGS ServiceMap smap = mServiceMap.get(userId); if (smap != null) { for (int i = 0; i < smap.mServicesByInstanceName.size(); i++) { Loading
services/core/java/com/android/server/am/ActivityManagerService.java +4 −6 Original line number Diff line number Diff line Loading @@ -350,8 +350,6 @@ import com.android.internal.util.Preconditions; import com.android.internal.util.function.DecFunction; import com.android.internal.util.function.HeptFunction; import com.android.internal.util.function.HexFunction; import com.android.internal.util.function.NonaFunction; import com.android.internal.util.function.OctFunction; import com.android.internal.util.function.QuadFunction; import com.android.internal.util.function.QuintFunction; import com.android.internal.util.function.TriFunction; Loading Loading @@ -16085,11 +16083,11 @@ public class ActivityManagerService extends IActivityManager.Stub } @Override public void onForegroundServiceNotificationUpdate(Notification notification, int id, String pkg, @UserIdInt int userId) { public void onForegroundServiceNotificationUpdate(boolean shown, Notification notification, int id, String pkg, @UserIdInt int userId) { synchronized (ActivityManagerService.this) { mServices.onForegroundServiceNotificationUpdateLocked(notification, id, pkg, userId); mServices.onForegroundServiceNotificationUpdateLocked(shown, notification, id, pkg, userId); } }
services/core/java/com/android/server/notification/NotificationManagerService.java +12 −9 Original line number Diff line number Diff line Loading @@ -3052,17 +3052,19 @@ public class NotificationManagerService extends SystemService { } } protected void maybeReportForegroundServiceUpdate(final NotificationRecord r) { protected void reportForegroundServiceUpdate(boolean shown, final Notification notification, final int id, final String pkg, final int userId) { mHandler.post(() -> { mAmi.onForegroundServiceNotificationUpdate(shown, notification, id, pkg, userId); }); } protected void maybeReportForegroundServiceUpdate(final NotificationRecord r, boolean shown) { if (r.isForegroundService()) { // snapshot live state for the asynchronous operation final StatusBarNotification sbn = r.getSbn(); final Notification notification = sbn.getNotification(); final int id = sbn.getId(); final String pkg = sbn.getPackageName(); final int userId = sbn.getUser().getIdentifier(); mHandler.post(() -> { mAmi.onForegroundServiceNotificationUpdate(notification, id, pkg, userId); }); reportForegroundServiceUpdate(shown, sbn.getNotification(), sbn.getId(), sbn.getPackageName(), sbn.getUser().getIdentifier()); } } Loading Loading @@ -6194,6 +6196,7 @@ public class NotificationManagerService extends SystemService { // because the service lifecycle logic has retained responsibility for its // handling. if (!isNotificationShownInternal(pkg, tag, id, userId)) { reportForegroundServiceUpdate(false, notification, id, pkg, userId); return; } } Loading Loading @@ -7121,7 +7124,7 @@ public class NotificationManagerService extends SystemService { maybeRecordInterruptionLocked(r); maybeRegisterMessageSent(r); maybeReportForegroundServiceUpdate(r); maybeReportForegroundServiceUpdate(r, true); // Log event to statsd mNotificationRecordLogger.maybeLogNotificationPosted(r, old, position, Loading