1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| NotificationManager.java (framework) | notify() | notifyAsUser() | service.enqueueNotificationWithTag( , , , , fixNotification (), ) NotificationManagerService.java (framework) | enqueueNotificationWithTag() | enqueueNotificationInternal() | enqueueNotificationInternal( , , ) | enqueueNotificationInternal( , , , , ) | fixNotification() | StatusBarNotification | NotificationChannel | NotificationRecord | checkDisqualifyingFeatures() | mHandler.post(new EnqueueNotificationRunnable(userId, r, isAppForeground, tracker)); EnqueueNotificationRunnable implements Runnable | enqueueNotification() | PostNotificationRunnable PostNotificationRunnable | postNotification() | notifyListenersPostedAndLogLocked() | prepareNotifyPostedLocked() --> NotificationListeners#prepareNotifyPostedLocked() class NotificationListeners (NotificationManagerService.java里) if (oldSbnVisible && !sbnVisible) { final StatusBarNotification oldSbnLightClone = oldSbn.cloneLight(); listenerCalls.add(() -> notifyRemoved( info, oldSbnLightClone, update, null, REASON_USER_STOPPED)); continue; } 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()
|