Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3325cbb authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "resolved conflicts for merge of 0a931069 to lmp-dev" into lmp-dev

parents a1b6cfd7 aa9b0f15
Loading
Loading
Loading
Loading
+2 −36
Original line number Diff line number Diff line
@@ -364,28 +364,6 @@ public final class ActivityManagerService extends ActivityManagerNative
    // devices.
    private boolean mShowDialogs = true;
    /**
     * Description of a request to start a new activity, which has been held
     * due to app switches being disabled.
     */
    static class PendingActivityLaunch {
        final ActivityRecord r;
        final ActivityRecord sourceRecord;
        final int startFlags;
        final ActivityStack stack;
        PendingActivityLaunch(ActivityRecord _r, ActivityRecord _sourceRecord,
                int _startFlags, ActivityStack _stack) {
            r = _r;
            sourceRecord = _sourceRecord;
            startFlags = _startFlags;
            stack = _stack;
        }
    }
    final ArrayList<PendingActivityLaunch> mPendingActivityLaunches
            = new ArrayList<PendingActivityLaunch>();
    BroadcastQueue mFgBroadcastQueue;
    BroadcastQueue mBgBroadcastQueue;
    // Convenient for easy iteration over the queues. Foreground is first
@@ -1438,7 +1416,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            } break;
            case DO_PENDING_ACTIVITY_LAUNCHES_MSG: {
                synchronized (ActivityManagerService.this) {
                    doPendingActivityLaunchesLocked(true);
                    mStackSupervisor.doPendingActivityLaunchesLocked(true);
                }
            } break;
            case KILL_APPLICATION_MSG: {
@@ -3339,19 +3317,6 @@ public final class ActivityManagerService extends ActivityManagerNative
        mProcessObservers.finishBroadcast();
    }
    final void doPendingActivityLaunchesLocked(boolean doResume) {
        final int N = mPendingActivityLaunches.size();
        if (N <= 0) {
            return;
        }
        for (int i=0; i<N; i++) {
            PendingActivityLaunch pal = mPendingActivityLaunches.get(i);
            mStackSupervisor.startActivityUncheckedLocked(pal.r, pal.sourceRecord, null, null, pal.startFlags,
                    doResume && i == (N-1), null);
        }
        mPendingActivityLaunches.clear();
    }
    @Override
    public final int startActivity(IApplicationThread caller, String callingPackage,
            Intent intent, String resolvedType, IBinder resultTo,
@@ -9140,6 +9105,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    @Override
    public void stopAppSwitches() {
        if (checkCallingPermission(android.Manifest.permission.STOP_APP_SWITCHES)
                != PackageManager.PERMISSION_GRANTED) {
+9 −3
Original line number Diff line number Diff line
@@ -2732,18 +2732,23 @@ final class ActivityStack {
        return r;
    }

    void finishAllActivitiesLocked() {
    void finishAllActivitiesLocked(boolean immediately) {
        boolean noActivitiesInStack = true;
        for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
            final ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities;
            for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
                final ActivityRecord r = activities.get(activityNdx);
                if (r.finishing) {
                noActivitiesInStack = false;
                if (r.finishing && !immediately) {
                    continue;
                }
                Slog.d(TAG, "finishAllActivitiesLocked: finishing " + r);
                Slog.d(TAG, "finishAllActivitiesLocked: finishing " + r + " immediately");
                finishCurrentActivityLocked(r, FINISH_IMMEDIATELY, false);
            }
        }
        if (noActivitiesInStack) {
            mActivityContainer.onTaskListEmptyLocked();
        }
    }

    final boolean navigateUpToLocked(IBinder token, Intent destIntent, int resultCode,
@@ -2858,6 +2863,7 @@ final class ActivityStack {
        // down to the max limit while they are still waiting to finish.
        mStackSupervisor.mFinishingActivities.remove(r);
        mStackSupervisor.mWaitingVisibleActivities.remove(r);
        mStackSupervisor.removePendingActivityLaunchesLocked(r);

        // Remove any pending results.
        if (r.finishing && r.pendingResults != null) {
+46 −6
Original line number Diff line number Diff line
@@ -98,7 +98,6 @@ import com.android.internal.app.IVoiceInteractor;
import com.android.internal.os.TransferPipe;
import com.android.internal.statusbar.IStatusBarService;
import com.android.server.LocalServices;
import com.android.server.am.ActivityManagerService.PendingActivityLaunch;
import com.android.server.am.ActivityStack.ActivityState;
import com.android.server.wm.WindowManagerService;

@@ -271,6 +270,28 @@ public final class ActivityStackSupervisor implements DisplayListener {
     */
    private LockTaskNotify mLockTaskNotify;

    final ArrayList<PendingActivityLaunch> mPendingActivityLaunches
            = new ArrayList<PendingActivityLaunch>();

    /**
     * Description of a request to start a new activity, which has been held
     * due to app switches being disabled.
     */
    static class PendingActivityLaunch {
        final ActivityRecord r;
        final ActivityRecord sourceRecord;
        final int startFlags;
        final ActivityStack stack;

        PendingActivityLaunch(ActivityRecord _r, ActivityRecord _sourceRecord,
                int _startFlags, ActivityStack _stack) {
            r = _r;
            sourceRecord = _sourceRecord;
            startFlags = _startFlags;
            stack = _stack;
        }
    }

    public ActivityStackSupervisor(ActivityManagerService service) {
        mService = service;
        mHandler = new ActivityStackSupervisorHandler(mService.mHandler.getLooper());
@@ -1421,7 +1442,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
            if (!mService.checkAppSwitchAllowedLocked(callingPid, callingUid, "Activity start")) {
                PendingActivityLaunch pal =
                        new PendingActivityLaunch(r, sourceRecord, startFlags, stack);
                mService.mPendingActivityLaunches.add(pal);
                mPendingActivityLaunches.add(pal);
                setDismissKeyguard(false);
                ActivityOptions.abort(options);
                return ActivityManager.START_SWITCHES_CANCELED;
@@ -1439,7 +1460,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
            mService.mDidAppSwitch = true;
        }

        mService.doPendingActivityLaunchesLocked(false);
        doPendingActivityLaunchesLocked(false);

        err = startActivityUncheckedLocked(r, sourceRecord, voiceSession, voiceInteractor,
                startFlags, true, options);
@@ -2008,6 +2029,23 @@ public final class ActivityStackSupervisor implements DisplayListener {
        return ActivityManager.START_SUCCESS;
    }

    final void doPendingActivityLaunchesLocked(boolean doResume) {
        while (!mPendingActivityLaunches.isEmpty()) {
            PendingActivityLaunch pal = mPendingActivityLaunches.remove(0);
            startActivityUncheckedLocked(pal.r, pal.sourceRecord, null, null, pal.startFlags,
                    doResume && mPendingActivityLaunches.isEmpty(), null);
        }
    }

    void removePendingActivityLaunchesLocked(ActivityRecord r) {
        for (int palNdx = mPendingActivityLaunches.size() - 1; palNdx >= 0; --palNdx) {
            PendingActivityLaunch pal = mPendingActivityLaunches.get(palNdx);
            if (pal.r == r) {
                mPendingActivityLaunches.remove(palNdx);
            }
        }
    }

    void acquireLaunchWakelock() {
        if (VALIDATE_WAKE_LOCK_CALLER && Binder.getCallingUid() != Process.myUid()) {
            throw new IllegalStateException("Calling must be system uid");
@@ -3312,7 +3350,9 @@ public final class ActivityStackSupervisor implements DisplayListener {
                    synchronized (mService) {
                        Slog.w(TAG, "Timeout waiting for all activities in task to finish. " +
                                msg.obj);
                        ((ActivityContainer) msg.obj).onTaskListEmptyLocked();
                        final ActivityContainer container = (ActivityContainer) msg.obj;
                        container.mStack.finishAllActivitiesLocked(true);
                        container.onTaskListEmptyLocked();
                    }
                } break;
                case LAUNCH_TASK_BEHIND_COMPLETE: {
@@ -3414,11 +3454,11 @@ public final class ActivityStackSupervisor implements DisplayListener {

                final Message msg =
                        mHandler.obtainMessage(CONTAINER_TASK_LIST_EMPTY_TIMEOUT, this);
                mHandler.sendMessageDelayed(msg, 1000);
                mHandler.sendMessageDelayed(msg, 2000);

                long origId = Binder.clearCallingIdentity();
                try {
                    mStack.finishAllActivitiesLocked();
                    mStack.finishAllActivitiesLocked(false);
                } finally {
                    Binder.restoreCallingIdentity(origId);
                }