App:
android.app.Activity#finish(int)
android.app.ActivityClient#finishActivity()
ipc to ams:
com.android.server.wm.ActivityClientController#finishActivity()
com.android.server.wm.ActivityRecord#finishIfPossible()
When DestroyActivityItem#obtain is called:
com.android.server.wm.ActivityTaskSupervisor#processStoppingAndFinishingActivities(): first stop then finish
com.android.server.wm.ActivityRecord#destroyIfPossible()
com.android.server.wm.ActivityRecord#destroyImmediately()
calls:
mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token,
DestroyActivityItem.obtain(finishing, configChangeFlags));
When Activity#onDestory() is called:
server side :
com.android.server.wm.ActivityRecord#destroyImmediatel() calll this :
mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token,
DestroyActivityItem.obtain(finishing, configChangeFlags));
then goto client side:
java.lang.RuntimeException: Unable to destroy activity
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5424)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5457)
at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:47)
at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:179)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2306)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7918)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
because ActivityThread get a DestroyActivityItem from ams.
Who calls ActivityRecord#destroyImmediatel() ?:
com.android.server.wm.ActivityRecord#destroyIfPossible()
com.android.server.wm.ActivityTaskSupervisor#processStoppingAndFinishingActivities()
When com.android.server.wm.ActivityClientController#activityIdle is called:
app side is android.app.ActivityClient#activityIdle()
What is a IdleHandler :
Callback interface for discovering when a thread is going to block waiting for more messages.
DESTRO TIMEOUT is 10s
// How long we wait until giving up on an activity telling us it has
// finished destroying itself.
private static final int DESTROY_TIMEOUT = 10 * 1000;