android 6.0 activitymanagerservice keyword

在AMS中service默认处理timeout时间, 如果超过就会引发ANR。
@ActiveServices.java

    // 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;

@AMS MainHandler即AMS主线程会主要处理下面这些MSG:

UPDATE_CONFIGURATION_MSG
GC_BACKGROUND_PROCESSES_MSG
SERVICE_TIMEOUT_MSG
UPDATE_TIME_ZONE
CLEAR_DNS_CACHE_MSG
UPDATE_HTTP_PROXY_MSG
PROC_START_TIMEOUT_MSG
CONTENT_PROVIDER_PUBLISH_TIMEOUT_MSG
DO_PENDING_ACTIVITY_LAUNCHES_MSG
KILL_APPLICATION_MSG
FINALIZE_PENDING_INTENT_MSG
POST_HEAVY_NOTIFICATION_MSG

一般退出 handler线程可通过looper的quit函数:
mHandlerThread.getLooper().quit();

UiHandler android.ui thread
AMS也会把下面MSG放到android.ui线程中:

SHOW_ERROR_MSG
SHOW_NOT_RESPONDING_MSG
SHOW_STRICT_MODE_VIOLATION_MSG
SHOW_FACTORY_ERROR_MSG
WAIT_FOR_DEBUGGER_MSG
SHOW_UID_ERROR_MSG
SHOW_FINGERPRINT_ERROR_MSG
SHOW_COMPAT_MODE_DIALOG_MSG:
START_USER_SWITCH_MSG
DISMISS_DIALOG_MSG

DISPATCH_PROCESSES_CHANGED
DISPATCH_PROCESS_DIED
DISPATCH_UIDS_CHANGED_MSG

AMS中处理broadcast时,也会有时间要求,超过也会引发ANR。
BROADCAST TIMEOUT:

    // How long we allow a receiver to run before giving up on it.
    static final int BROADCAST_FG_TIMEOUT = 10*1000;
    static final int BROADCAST_BG_TIMEOUT = 60*1000;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章