8.5 Android灯光系统_源码分析_通知灯


参考文章(应用程序举例)
how to use the LED with Android phone
http://androidblogger.blogspot.jp/2009/09/tutorial-how-to-use-led-with-android.html

通知的种类有声音、震动、闪灯

App怎么发财“通知灯”请求

(1)getSystemService获得通知服务

(2)构造notification

(3)发出通知

系统如何处理?

(1)启动“通知”Service

(2)收到通知后,分配通知类型,执行相应操作

对于灯光的相应操作:

(1)获得LightsService

(2)执行灯光操作

通知灯的服务应用在NotificationManagerService.java中

通知灯使用过程:
a. SystemServer.java : 注册Notification服务
b. app的上下文context里有静态块,它会注册服务: registerService(NOTIFICATION_SERVICE)//在contextImpl.java中注册
c. app: nm = getSystemService //nm就是NotificationManager实例化对象
d. 构造Notification
e. 设置参数: 通知类型、颜色、时间
f. nm.notify
f.1 getService 得到的是 "SystemServer注册的Notification服务"//

 调用service.enqueueNotificationWithTag
f.2 最终判断通知类型进而调用到通知灯的JNI函数

原文地址:https://www.cnblogs.com/liusiluandzhangkun/p/9131261.html