Accessibility service disabled upon each debug run

后端 未结 1 985
灰色年华
灰色年华 2021-02-03 17:26

Each time I start a new debug instance, my accessibility service resets to the disabled state.

Is there any way to keep it enabled across successive debug runs (as it is

相关标签:
1条回答
  • 2021-02-03 17:39

    This might go some way to explain and mitigate your problem (but not what causes your Force stop).

    After Android 3.1 " the system sets FLAG_EXCLUDE_STOPPED_PACKAGES on all broadcast intents." So after 3.1 , all apps are stopped on boot. Why ?. For security reasons.

    There are RULES to turn the flag off FLAG_EXCLUDE_STOPPED_PACKAGES.

    (1) If the app get's a Force stop from settings OR unresponsive app button, the flag is set.

    (2) Your app needs to be in Phone Storage, NOT external storage (e.g. sdcard) otherwise the flag set. The BOOT_COMPLETE is sent before external storage is mounted. So, if app is installed to external storage it won't receive BOOT_COMPLETE broadcast message.

    (3) If the application has never been run, the flag is set (never is relative to current boot state ;O) NEVER means in THIS boot OR you invalidated the flag in the last boot state).

    A quick way (scripted if you like) to re-enable your service after Force stop assuming BOOT_COMPLETED receiver (I'm guessing you have this, because your fine after reboot):

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"
    
    adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
    

    See launchcontrols

    0 讨论(0)
提交回复
热议问题