资源描述:
《Android从上层到底层完整流程.docx》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Android上层界面到内核代码的完整的流程分析,以alarm为例子很久之前写的一个流程文档,从上层界面一直调用到内核的过程,最近同事跟我要,我看了下又在整理了下,纯属个人分析(不过都运行验证过),不对的请大牛指出。Alarm调用流程,alarm的流程实现了从上层应用一直到下面driver的调用流程,下面简单阐述:涉及代码;./packages/apps/DeskClock/src/com/android/deskclock/Alarms.java./frameworks/base/core/java/an
2、droid/app/AlarmManager.java./frameworks/base/services/java/com/android/server/AlarmManagerService.java./frameworks/base/services/jni/com_android_server_AlarmManagerService.cpp./kernel/kernel/drivers/rtc/alarm-dev.c./kernel/kernel/include/linux/android_alar
3、m.h./kernel/kernel/drivers/rtc/alarm.c./kernel/kernel/drivers/rtc/interface.c21/21./kernel/kernel/drivers/rtc/rtc-pcf8563.c/packages/apps/DeskClock/src/com/android/deskclock/AlarmReceiver.java./kernel/arch/arm/configs/mmp2_android_defconfig./kernel/kernel/
4、kernel/.config 点击Clock应用程序,然后设置新闹钟,会调到Alarms.java里面的publicstaticlongsetAlarm(Contextcontext,Alarmalarm){....setNextAlert(context);....}然后这里面也会调用到 publicstaticvoidsetNextAlert(finalContextcontext){21/21 if(!enableSnoozeAlert(context)){ Alar
5、malarm=calculateNextAlert(context);//new一个新的alarm if(alarm!=null){ enableAlert(context,alarm,alarm.time); }else{ disableAlert(context); } } }然后继续调用到privatestaticvoidenableAlert(Contextcontex
6、t,finalAlarmalarm,finallongatTimeInMillis){.......am.set(AlarmManager.RTC_WAKEUP,atTimeInMillis,sender);//这里是RTC_WAKEUP,这就保证了即使系统睡眠了,都能唤醒,闹钟工作(android平台关机闹钟好像不行).....21/21}然后就调用到了AlarmManager.java里面方法 publicvoidset(inttype,longtriggerAtTime,PendingIntent
7、operation){ try{ mService.set(type,triggerAtTime,operation); }catch(RemoteExceptionex){ } }然后就调用到了AlarmManagerService.java 里面方法publicvoidset(inttype,longtriggerAtTime,PendingIntentoperation){ setRepeating(type,triggerAtT
8、ime,0,operation); }21/21然后继续调用publicvoidsetRepeating(inttype,longtriggerAtTime,longinterval, PendingIntentoperation){.....synchronized(mLock){ Alarmalarm=newAlarm(); alarm.type