关键类:
NotificationManger NotificationManagerService EnqueueNotificationRunnable PostNotificationRunnable的处理 NotificationListeners
NotificationManger:
1)对smallicon的非空检验(Build.VERSION_CODES.LOLLIPOP_MR1以上版本),校验不通过报IllegalArgumentException("Invalid notification (no valid small icon),日志上有明显的提示,可以通过此条打印定位crash原因。
2)对LargeIcon压缩(若超过最大宽高MediaStyle(H:140dp W:280dp) BigPictureStyle(H:284dp W:416dp) 其他40dp),若未达到阀值则居中显示。
NotificationManagerService:
检验Caller是否合法(主要是针对多用户的非管理用户的限制)
参数是否合法(对nofiticaiton和packageName进行非空校验)
是否能被渲染(猜测是沉浸式状态栏相关设置,只有系统APP才可以设置)
保存通知状态(分为全局和根据Pakcagename区分的应用程序的)
校验ChannelId是否合法(ChannelId是否成功注册了)
封装Notification的相关信息到StatusBarNotification(实现Parcelable接口,用来给SystemUI传输数据)
创建NotificationRecord,用来保存framework层私有数据(也就是不发送给SystemUI的数据)和StatusBarNotification。简单理解就是所有的通知数据;
通知限制处理:
1):即时应用不允许发送通知;2):通知的刷新频率不能太快,并且进度条通知的进度不能大于或等于最大值;3):每个应用最多能同时存在50个通知
布局一:android:id/app_name_text图标旁文字 android:id/title android:id/text
布局二:com.android.systemui:id/header_label(头标题)
android:id/app_name_text android:id/time_divider android:id/time android:id/alerted_icon
android:id/title android:id/expand_button(扩展按钮) android:id/title com.android.systemui android:id/action0
android:id/notification_header android:id/app_ops(显示有几条信息)
com.android.systemui:id/notification_title(通知标题) com.android.systemui:id/notification_text(通知信息)
清空所有通知:com.android.systemui:id/clear_all_port
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)