Mobilock app starts before BOOT_COMPLETED broadcast… How is it possible?

扶醉桌前 提交于 2019-12-04 02:03:29

问题


There is a kiosk app called Mobilock. This app starts way faster (Almost 5 seconds before) than my own app which starts with BOOT_COMPLETED broadcast.

My own app has the highest priority which is max value of integer. So this is not about the priority.

These guys have found a way to start their application 5 second sooner than BOOT_COMPLETED broadcast.

Has anyone got an idea about what they are doing?


回答1:


Listen also to android.intent.action.QUICKBOOT_POWERON and android.intent.action.LOCKED_BOOT_COMPLETED.

It seems to be device-dependant, which broadcast is sent first.




回答2:


Oh my god! I've luckily found it. :)

This Page Says : Apps must register their components with the system before they can run during Direct Boot mode or access device encrypted storage. Apps register with the system by marking components as encryption aware. To mark your component as encryption aware, set the android:directBootAware attribute to true in your manifest.

Encryption aware components can register to receive a ACTION_LOCKED_BOOT_COMPLETED broadcast message from the system when the device has been restarted. At this point device encrypted storage is available, and your component can execute tasks that need to be run during Direct Boot mode, such as triggering a scheduled alarm.

You just need to put

android:directBootAware="true"

So the code in manifest is;

<receiver
  android:directBootAware="true" >
  ...
 <intent-filter>
  <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
 </intent-filter>
</receiver>


来源:https://stackoverflow.com/questions/48091317/mobilock-app-starts-before-boot-completed-broadcast-how-is-it-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!