NotificationManager.java (framework)
| notify()
| notifyAsUser()
| service.enqueueNotificationWithTag( , , , , fixNotification (), )
NotificationManagerService.java (framework)
| enqueueNotificationWithTag()
| enqueueNotificationInternal()
| enqueueNotificationInternal( , , )
| enqueueNotificationInternal( , , , , )
| fixNotification()
| StatusBarNotification // SystemUI 会用
| NotificationChannel
| NotificationRecord // framework 用
| checkDisqualifyingFeatures()
| mHandler.post(new EnqueueNotificationRunnable(userId, r, isAppForeground, tracker));
EnqueueNotificationRunnable implements Runnable
| enqueueNotification()
| PostNotificationRunnable
PostNotificationRunnable
| postNotification()
| notifyListenersPostedAndLogLocked()
| prepareNotifyPostedLocked() --> NotificationListeners#prepareNotifyPostedLocked()
class NotificationListeners (NotificationManagerService.java里)
// notifyRemoved
// This notification became invisible -> remove the old one.
if (oldSbnVisible && !sbnVisible) {
final StatusBarNotification oldSbnLightClone = oldSbn.cloneLight();
listenerCalls.add(() -> notifyRemoved(
info, oldSbnLightClone, update, null, REASON_USER_STOPPED));
continue;
}
// notifyPosted
final StatusBarNotification sbnToPost = trimCache.ForListener(info);
listenerCalls.add(() -> notifyPosted(info, sbnToPost, update));
private void notifyPosted(final ManagedServiceInfo info,
final StatusBarNotification sbn, NotificationRankingUpdate rankingUpdate) {
final INotificationListener listener = (INotificationListener) info.service;
StatusBarNotificationHolder sbnHolder = new StatusBarNotificationHolder(sbn);
try {
listener.onNotificationPosted(sbnHolder, rankingUpdate);
} catch (android.os.DeadObjectException ex) {
Slog.wtf(TAG, "unable to notify listener (posted): " + info, ex);
} catch (RemoteException ex) {
Slog.e(TAG, "unable to notify listener (posted): " + info, ex);
}
}
NotificationListener.java (SystemUI)
onNotificationPosted()
interface NotificationHandler (是NotificationListener.java 内部接口)
onNotificationPosted()