每次调试运行时都禁用辅助功能服务

Jér*_*aud 52 debugging android accessibilityservice

每次启动新的调试实例时,我的辅助功能服务都会重置为禁用状态.

是否有任何方法可以在连续的调试运行中保持启用(因为每次启用调试服务都很长很无聊)?

我在真实设备和模拟器上有相同的行为.
服务中没有异常,我在事件处理程序中尝试了没有代码的事件.

我的日志中有可疑的行:

10:47:32.801 31669-31669/? E/AffinityControl: AffinityControl: registerfunction enter
10:47:32.821 3650-3690/? I/ActivityManager: Force stopping com.test.testaccessibilityservice appid=10241 user=0: from pid 31669
10:47:32.821 3650-3690/? I/ActivityManager: Killing 31271:com.test.testaccessibilityservice/u0a241 (adj 1): stop com.test.testaccessibilityservice cause from pid     
10:47:32.821 3650-3690/? W/ActivityManager: Scheduling restart of crashed service com.test.testaccessibilityservice/.MyAccessibilityService in 1000ms
10:47:32.821 3650-3690/? I/ActivityManager:   Force stopping service ServiceRecord{3f5e1fc4 u0 com.test.testaccessibilityservice/.MyAccessibilityService}
Run Code Online (Sandbox Code Playgroud)

因此服务被强制停止并且从未重新启动.

笔记:

  • 如果我重新启动手机,则启动该服务.
  • 我对ApiDemos示例和ClockBackService(QueryBackService)也有相同的行为:

    18:07:15.871 3523-4251/? I/ActivityManager: Force stopping com.example.android.apis appid=10242 user=0: from pid 19382
    18:07:15.871 3523-4251/? I/ActivityManager: Killing 16542:com.example.android.apis/u0a242 (adj 1): stop com.example.android.apis cause from pid 19382
    18:07:15.871 3523-4251/? W/ActivityManager: Scheduling restart of crashed service com.example.android.apis/.accessibility.ClockBackService in 1000ms
    18:07:15.871 3523-4251/? I/ActivityManager:   Force finishing activity 3 ActivityRecord{2f907c7b u0 com.example.android.apis/.ApiDemos t8248}
    18:07:15.881 3523-4251/? I/ActivityManager:   Force finishing activity 3 ActivityRecord{190ca05c u0 com.example.android.apis/.ApiDemos t8248}
    18:07:15.881 3523-4251/? I/ActivityManager:   Force finishing activity 3 ActivityRecord{27ada6e8 u0 com.example.android.apis/.accessibility.ClockBackActivity t8248}
    18:07:15.881 3523-4251/? I/ActivityManager:   Force finishing activity 3 ActivityRecord{51f4c32 u0 com.android.settings/.Settings$AccessibilitySettingsActivity t8248}
    18:07:15.881 3523-4251/? I/ActivityManager:   Force stopping service ServiceRecord{113bf024 u0 com.example.android.apis/.accessibility.ClockBackService}
    18:07:15.891 19382-19382/? D/AndroidRuntime: Shutting down VM
    
    Run Code Online (Sandbox Code Playgroud)

我试图通过覆盖onStartCommand而不做任何更改来返回START_STICKY.

它对这个尚未解决的问题非常封闭如何调试辅助功能服务?,但在我的情况下,该服务显示为禁用,我不需要停止它并再次启动它.

在AOSP上填写了这个错误报告.

Jon*_*win 1

这可能会在某种程度上解释缓解您的问题(但不是导致您的问题的原因Force stop)。

Android 3.1在“系统设置FLAG_EXCLUDE_STOPPED_PACKAGES所有广播意图”之后。因此,在 3.1 之后,所有应用程序都会在启动时停止。为什么 ?。出于安全原因。

关闭标志的 FLAG_EXCLUDE_STOPPED_PACKAGES规则。

(1)Force stop如果应用程序从设置或按钮中获取unresponsive app,则设置该标志。

(2) 您的应用程序需要位于Phone Storage而不是 external storage(例如sdcard),否则设置标志。在安装外部存储BOOT_COMPLETE之前发送。因此,如果应用程序安装到外部存储,它将不会收到 BOOT_COMPLETE 广播消息。

(3) 如果应用程序从未运行过,则设置该标志(从不与当前启动状态相关;O)从不表示在此启动中或您在上次启动状态中使该标志无效)。

在假设接收器后重新启用服务的快速方法(如果您愿意,可以编写脚本)(我猜您有这个,因为重新启动后就可以了):Force stopBOOT_COMPLETED

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
Run Code Online (Sandbox Code Playgroud)

查看启动控件

  • 抱歉,但我仍然认为这与此无关,问题涉及无障碍服务。答案将提供解决这种特殊问题的方法。 (3认同)