Android P Notification(2) 之 发送通知慢

1.通知log流程

在event log中搜索 notification_可以看到一个通知的整个流程。

大概是notification_enqueue  -- notification_expansion --notification_visibility -- notification_clicked -- notification_canceled

//notification_enqueue  把通知放入队列,要注意status 0 post 1 update,因此看event log可能会有几个,1个post ,另外都update

//notification_visibility代表通知显示到UI上

@ /frameworks/base/services/core/java/com/android/server/EventLogTags.logtags
59# when a NotificationManager.notify is called. status: 0=post, 1=update, 2=ignored
602750 notification_enqueue (uid|1|5),(pid|1|5),(pkg|3),(id|1|5),(tag|3),(userid|1|5),(notification|3),(status|1)

7427511 notification_expansion (key|3),(user_action|1),(expanded|1),(lifespan|1),(freshness|1),(exposure|1)

7627520 notification_clicked (key|3),(lifespan|1),(freshness|1),(exposure|1),(rank|1),(count|1)

79# when a notification has been canceled
8027530 notification_canceled (key|3),(reason|1),(lifespan|1),(freshness|1),(exposure|1),(rank|1),(count|1),(listener|3)
81# replaces 27510 with a row per notification
8227531 notification_visibility (key|3),(visibile|1),(lifespan|1),(freshness|1),(exposure|1),(rank|1)
83# a notification emited noise, vibration, or light
8427532 notification_alert (key|3),(buzz|1),(beep|1),(blink|1)

2.问题实例

碰到过一个bug关于来电通知慢的问题,大概要8s才显示通知,而正常显示应该是2s左右

分析步骤:

1.确认IncallUI收到电话到发出通知时间,如果没问题,证明tele没问题

2.确认notification_enqueue 到notification_visibility时间,确认framework notification 收到通知到显示在界面上的时间

3.发现notification_enqueue 到notification_visibility时间时间太久,导致

4.搜索systemUI pid查看main log发现,主线程一直在做其他事情,SystemUI主线程太忙导致,通知很慢

5.解决SystemUI移除循环耗时的地方

猜你喜欢

转载自blog.csdn.net/wd229047557/article/details/89191506