com.android.server.wm.Task#performClearTaskForReuse

clear all activities in the task :

    /**
     * Completely remove all activities associated with an existing task.
     */
    void performClearTaskForReuse(boolean excludingTaskOverlay) {
        mReuseTask = true;
        mTaskSupervisor.beginDeferResume();
        try {
            removeActivities("clear-task-all", excludingTaskOverlay);
        } finally {
            mTaskSupervisor.endDeferResume();
            mReuseTask = false;
        }
    }
    /** Completely remove all activities associated with an existing task. */
    void removeActivities(String reason, boolean excludingTaskOverlay) {
        clearPinnedTaskIfNeed();
        // Broken down into to cases to avoid object create due to capturing mStack.
        if (getRootTask() == null) {
            forAllActivities((r) -> {
                if (r.finishing || (excludingTaskOverlay && r.isTaskOverlay())) {
                    return;
                }
                // Task was restored from persistent storage.
                r.takeFromHistory();
                removeChild(r, reason);
            });
        } else {
            // Finish or destroy apps from the bottom to ensure that all the other activity have
            // been finished and the top task in another task gets resumed when a top activity is
            // removed. Otherwise, shell transitions wouldn't run because there would be no event
            // that sets the transition ready.
            final boolean traverseTopToBottom = !mTransitionController.isShellTransitionsEnabled();
            final ArrayList<ActivityRecord> finishingActivities = new ArrayList<>();
            forAllActivities(r -> {
                if (r.finishing || (excludingTaskOverlay && r.isTaskOverlay())) {
                    return;
                }
                finishingActivities.add(r);
            }, traverseTopToBottom);


            for (int i = 0; i < finishingActivities.size(); i++) {
                final ActivityRecord r = finishingActivities.get(i);

                // Prevent the transition from being executed too early if the top activity is
                // resumed but the mVisibleRequested of any other activity is true, the transition
                // should wait until next activity resumed.
                if (r.isState(RESUMED) || (r.isVisible()
                        && !mDisplayContent.mAppTransition.containsTransitRequest(TRANSIT_CLOSE))) {
                    r.finishIfPossible(reason, false /* oomAdj */);
                } else {
                    r.destroyIfPossible(reason);
                }
            }
        }
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值