Android应用的启动顺序网上有一大堆资料可以查阅了,这里就不细述了,这里不阐述ROM启动还有bootloader,软件启动的大致流程应该是启动kernel -> 运行servicemanager 把一些native的服务用命令启动起来(包括wifi, power, rild, surfaceflinger, mediaserver等等)-> 启动Dalivk中的第一个进程Zygote -> 启动java 层的系统服务system_server(包括PowerManagerService, ActivityManagerService , telephony.registry, DisplayManagerService等等)该服务中的这些部件跟native的那些服务关联在一起 -> 启动Luncher和Persistent的App,该程序是系统级的在AndroidManifest.xml里声明android:persistent="true" -> 发出ACTION_BOOT_COMPLETED广播给其他应用。
在这里需要注意的是声明android:persistent属性为true的APP被kill掉后还是会自动重启的。
系统中我们已知android:persistent属性为true的APP肯定有Phone App,也就是说第三方应用应当至少晚于Phone APP启动,如何判断呢?最简单的办法看其PID的大小,PID值越小越先启动。有其第三方应用可以先于Phone APP启动。我们探其应用的AndroidManifest.xml (PS:如何看APK的代码,网上有你懂的apktool等),发现其在AndroidManifest里定义的静态Receiver的intent-filter的属性如下:
<receiver android:name="com.anguanjia.safe.AAAReceiver">
<intent-filter android:priority="2147483647"></intent-filter></span>
<intent-filter android:priority="2147483647">
<data android:scheme="file">
</data></action></action></action></action></action></intent-filter>
</action></action></action></action></action></receiver>
2147483647 这个值是什么?好大,哦,原来是int的最大值!我们来看下google 文档
android:priority
The priority that should be given to the parent component with regard to handling intents of the type described by the filter. This attribute has meaning for both activities and broadcast receivers:
It provides information about how able an activity is to respond to an intent that matches the filter, relative to other activities that could also respond to the intent. When an intent could be handled by multiple activities with different priorities, Android will consider only those with higher priority values as potential targets for the intent.
It controls the order in which broadcast receivers are executed to receive broadcast messages. Those with higher priority values are called before those with lower values. (The order applies only to synchronous messages; it's ignored for asynchronous messages.)
Use this attribute only if you really need to impose a specific order in which the broadcasts are received, or want to force Android to prefer one activity over others.
The value must be an integer, such as "100". Higher numbers have a higher priority. The default value is 0. The value must be greater than -1000 and less than 1000.
这个值是receiver的优先级,值越大优先级越高,按优先顺序执行,但是文档介绍优先级值大小是-1000~1000. 该应用的是int的最大值, 但android平台没有对android:priority值进行检查。在开机后该应用Receiver的intent-filter的优先级最高,在该filter里的intent被系统发送出来(android.intent.action.MEDIA_MOUNTE, android.net.wifi.WIFI_STATE_CHANGED等等),这个时候App会根据这个intent而被启动起来。
这里需要注意的是该Receiver是个静态的,一定是要注册在AndroidManifest里。当Wifi成功注册后会发出WIFI_STATE_CHANGED的消息, 或者其他的部件完成一些事件后也会发出类似的消息,而这些消息的发出又早于属性为persistent的系统级APP的启动, 由此就会发生第三方应用早于系统级APP的启动的情况。
分享到:
相关推荐
android 把软件安装成系统软件(安装到system/app目录下)
System app remover系统应用删除10.1.13540专业版.rar
现在大多数的android手机系统都默认禁止第三方安装的APP开机自启动,只有系统APP(system/app)才默认有这个权限,所以一般都需要去安全中心或者手机管家中去设置为允许。这里说个题外话,手机软件除非特殊情况,不然...
系统程序卸载器_System App Remover_v4.13汉化版系统程序卸载器_System App Remover_v4.13汉化版
SystemAppMover, Android 应用 将其他应用程序从/system/app 文件夹移动到文件夹 SystemAppMover需要 root 使用你自己的风险 !这里应用将应用程序从/system/app 文件夹移动到文件夹,使它的成为系统应用程序或者...
系统程序卸载器 v4.19systemappremover_3.apk
SystemUI启动流程
android系统自带system/app
adb shell "cat /cache/backup/dbzm.apk > /system/app/dbzm.apk" adb shell "cat /cache/backup/stbconfig.ini > /data/ztecfg/stbconfig.ini" adb shell "cat /cache/backup/stbconfig.ini > /cache/reset/...
rom 一键解包 打包 做第三方rom工具 完美版CM 资源较大。功能较多。 工具支持; 解包打包boot和recovery 解包打包ODM格式任意 解包打包system格式 解包打包bat后缀格式 解包打包br后缀格式 解包打包odm。img 解包打包...
删除系统自带软件,要求root权限.
《Systemvue系统仿真技术应用讲义》目录: 第一章SystemVue与系统仿真技术基础; 第二章SystemVue系统设计基础; 第三章SystemVue系统仿真基础; 第四章:Systemvue雷达系统建模与仿真; 第五章:导航系统建模与仿真...
PsExec命令工具以SYSTEM身份运行进程,这里可以借助PsExec命令打开CMD命令提示符窗口,然后在命令提示符下运行DIR命令查看该文件下的内容,步骤如下: ⑴ 以管理员身份登录系统,打开CMD命令提示符窗口。 ⑵ 在命令...
可以以system用户运行任何程序,提高权限
能学到什么:①SSH(Struts2+Spring+hibernate)框架;②课程系统如何设计和开发。 阅读建议:此资源以项目为载体,整合SSH,学习其原理和内核,不仅是代码编写实现也更注重内容上的需求分析和方案设计,所以在学习...
现在的第三方安卓8.1rom里面的system.new.dat.br,怎么转成原来的system.new.dat 2015年9月, Google就已经在官方博客上发布了新的压缩算法Brotli, 并开源在了Github上.同时还发布了一个研究报告, 対Brotli, ...
系统应用 系统应用程序基于SIMbiosis1的应用程序使用的基本系统
破解Windows主题(uxtheme.dll) 方法一 ...再找到 uxtheme_cracked.dll,将其改名为 uxtheme.dl——重启系统——再进入 X:\Windows\System32,找到 uxtheme.dll.bak(就是你改了名的原 uxtheme.dll)
应用卸载-Uninstall App 应用卸载是一款安卓程序卸载利器,工具应用。 ①提供卸载应用程序功能,帮助清除掉手机上垃圾程序; ②采用智能直接删除程序文件,及其关联缓存文件等,轻松卸载程序; ③目前只支持卸载除...