ANR
机制描述:
(//ps:AOSP源码中Service的前台Service的TIMEOUT时间是20s,后台Service的TIMEOUT时间是200s)
android-10
// How long we wait for a service to finish executing.
static final int SERVICE_TIMEOUT = 20*1000;
// How long we wait for a service to finish executing.
static final int SERVICE_BACKGROUND_TIMEOUT = SERVICE_TIMEOUT * 10;原理:
Service:
前台Service启动超过20s没有启动完成:在Service启动时发送一个延迟20s的消息(该消息内部即为 报ANR并分析ANR栈),之后在Service的启动完成时将这个消息remove掉。如果成功remove那就啥事没有,如果超过20s没有remove就消息触发,执行消息体内的ANR动作。(后台消息)
https://segmentfault.com/a/1190000022967452