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

Commit 58d6fb4f authored by Wale Ogunwale's avatar Wale Ogunwale Committed by android-build-merger
Browse files

Merge "Revert "Collect NeededUriGrants without holding locks."" into qt-dev...

Merge "Revert "Collect NeededUriGrants without holding locks."" into qt-dev am: 2aa255a7 am: ef2a04ad
am: d04ecf01

Change-Id: Iccbb3ce3d8ca313a05c283ab13a07906dfa8706c
parents 400c2537 d04ecf01
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -43,14 +43,14 @@ public interface UriGrantsManagerInternal {
            int callingUid, String targetPkg, Uri uri, int modeFlags, int userId);
            int callingUid, String targetPkg, Uri uri, int modeFlags, int userId);
    NeededUriGrants checkGrantUriPermissionFromIntent(int callingUid,
    NeededUriGrants checkGrantUriPermissionFromIntent(int callingUid,
            String targetPkg, Intent intent, int mode, NeededUriGrants needed, int targetUserId);
            String targetPkg, Intent intent, int mode, NeededUriGrants needed, int targetUserId);
    NeededUriGrants checkGrantUriPermissionFromIntent(int callingUid,
            Intent intent, String targetPkg, int targetUserId);
    /**
    /**
     * Grant Uri permissions from one app to another. This method only extends
     * Grant Uri permissions from one app to another. This method only extends
     * permission grants if {@code callingUid} has permission to them.
     * permission grants if {@code callingUid} has permission to them.
     */
     */
    void grantUriPermissionFromIntent(int callingUid,
    void grantUriPermissionFromIntent(int callingUid,
            String targetPkg, Intent intent, int targetUserId);
            String targetPkg, Intent intent, int targetUserId);
    void grantUriPermissionFromIntent(int callingUid,
            String targetPkg, Intent intent, UriPermissionOwner owner, int targetUserId);
    void grantUriPermissionUncheckedFromIntent(
    void grantUriPermissionUncheckedFromIntent(
            NeededUriGrants needed, UriPermissionOwner owner);
            NeededUriGrants needed, UriPermissionOwner owner);
    IBinder newUriPermissionOwner(String name);
    IBinder newUriPermissionOwner(String name);
+6 −7
Original line number Original line Diff line number Diff line
@@ -1362,21 +1362,20 @@ public class UriGrantsManagerService extends IUriGrantsManager.Stub {
        }
        }


        @Override
        @Override
        public NeededUriGrants checkGrantUriPermissionFromIntent(int callingUid, Intent intent,
        public void grantUriPermissionFromIntent(int callingUid, String targetPkg, Intent intent,
                String targetPkg, int targetUserId) {
                int targetUserId) {
            synchronized (mLock) {
            synchronized (mLock) {
                final int mode = (intent != null) ? intent.getFlags() : 0;
                UriGrantsManagerService.this.grantUriPermissionFromIntent(
                return UriGrantsManagerService.this.checkGrantUriPermissionFromIntent(
                        callingUid, targetPkg, intent, null, targetUserId);
                        callingUid, targetPkg, intent, mode, null, targetUserId);
            }
            }
        }
        }


        @Override
        @Override
        public void grantUriPermissionFromIntent(int callingUid, String targetPkg, Intent intent,
        public void grantUriPermissionFromIntent(int callingUid, String targetPkg, Intent intent,
                int targetUserId) {
                UriPermissionOwner owner, int targetUserId) {
            synchronized (mLock) {
            synchronized (mLock) {
                UriGrantsManagerService.this.grantUriPermissionFromIntent(
                UriGrantsManagerService.this.grantUriPermissionFromIntent(
                        callingUid, targetPkg, intent, null, targetUserId);
                        callingUid, targetPkg, intent, owner, targetUserId);
            }
            }
        }
        }


+3 −5
Original line number Original line Diff line number Diff line
@@ -215,7 +215,6 @@ import com.android.server.AttributeCache;
import com.android.server.AttributeCache.Entry;
import com.android.server.AttributeCache.Entry;
import com.android.server.am.AppTimeTracker;
import com.android.server.am.AppTimeTracker;
import com.android.server.am.PendingIntentRecord;
import com.android.server.am.PendingIntentRecord;
import com.android.server.uri.NeededUriGrants;
import com.android.server.uri.UriPermissionOwner;
import com.android.server.uri.UriPermissionOwner;
import com.android.server.wm.ActivityMetricsLogger.WindowingModeTransitionInfoSnapshot;
import com.android.server.wm.ActivityMetricsLogger.WindowingModeTransitionInfoSnapshot;
import com.android.server.wm.ActivityStack.ActivityState;
import com.android.server.wm.ActivityStack.ActivityState;
@@ -1600,11 +1599,10 @@ final class ActivityRecord extends ConfigurationContainer {
     * Deliver a new Intent to an existing activity, so that its onNewIntent()
     * Deliver a new Intent to an existing activity, so that its onNewIntent()
     * method will be called at the proper time.
     * method will be called at the proper time.
     */
     */
    final void deliverNewIntentLocked(int callingUid, Intent intent, NeededUriGrants intentGrants,
    final void deliverNewIntentLocked(int callingUid, Intent intent, String referrer) {
            String referrer) {
        // The activity now gets access to the data associated with this Intent.
        // The activity now gets access to the data associated with this Intent.
        mAtmService.mUgmInternal.grantUriPermissionUncheckedFromIntent(intentGrants,
        mAtmService.mUgmInternal.grantUriPermissionFromIntent(callingUid, packageName,
                getUriPermissionsLocked());
                intent, getUriPermissionsLocked(), mUserId);
        final ReferrerIntent rintent = new ReferrerIntent(intent, referrer);
        final ReferrerIntent rintent = new ReferrerIntent(intent, referrer);
        boolean unsent = true;
        boolean unsent = true;
        final boolean isTopActivityWhileSleeping = isTopRunningActivity() && isSleeping();
        final boolean isTopActivityWhileSleeping = isTopRunningActivity() && isSleeping();
+47 −49
Original line number Original line Diff line number Diff line
@@ -163,7 +163,6 @@ import com.android.server.am.ActivityManagerService.ItemMatcher;
import com.android.server.am.AppTimeTracker;
import com.android.server.am.AppTimeTracker;
import com.android.server.am.EventLogTags;
import com.android.server.am.EventLogTags;
import com.android.server.am.PendingIntentRecord;
import com.android.server.am.PendingIntentRecord;
import com.android.server.uri.NeededUriGrants;


import java.io.FileDescriptor;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.PrintWriter;
@@ -2782,7 +2781,7 @@ class ActivityStack extends ConfigurationContainer {
            if (DEBUG_STATES) Slog.d(TAG_STATES,
            if (DEBUG_STATES) Slog.d(TAG_STATES,
                    "no-history finish of " + mLastNoHistoryActivity + " on new resume");
                    "no-history finish of " + mLastNoHistoryActivity + " on new resume");
            requestFinishActivityLocked(mLastNoHistoryActivity.appToken, Activity.RESULT_CANCELED,
            requestFinishActivityLocked(mLastNoHistoryActivity.appToken, Activity.RESULT_CANCELED,
                    null, null, "resume-no-history", false);
                    null, "resume-no-history", false);
            mLastNoHistoryActivity = null;
            mLastNoHistoryActivity = null;
        }
        }


@@ -3016,7 +3015,7 @@ class ActivityStack extends ConfigurationContainer {
                // If any exception gets thrown, toss away this
                // If any exception gets thrown, toss away this
                // activity and try the next one.
                // activity and try the next one.
                Slog.w(TAG, "Exception thrown during resume of " + next, e);
                Slog.w(TAG, "Exception thrown during resume of " + next, e);
                requestFinishActivityLocked(next.appToken, Activity.RESULT_CANCELED, null, null,
                requestFinishActivityLocked(next.appToken, Activity.RESULT_CANCELED, null,
                        "resume-exception", true);
                        "resume-exception", true);
                return true;
                return true;
            }
            }
@@ -3426,7 +3425,7 @@ class ActivityStack extends ConfigurationContainer {
                    if (DEBUG_TASKS) Slog.w(TAG_TASKS,
                    if (DEBUG_TASKS) Slog.w(TAG_TASKS,
                            "resetTaskIntendedTask: calling finishActivity on " + p);
                            "resetTaskIntendedTask: calling finishActivity on " + p);
                    if (finishActivityLocked(
                    if (finishActivityLocked(
                            p, Activity.RESULT_CANCELED, null, null, "reset-task", false)) {
                            p, Activity.RESULT_CANCELED, null, "reset-task", false)) {
                        end--;
                        end--;
                        srcPos--;
                        srcPos--;
                    }
                    }
@@ -3505,7 +3504,7 @@ class ActivityStack extends ConfigurationContainer {
                            continue;
                            continue;
                        }
                        }
                        finishActivityLocked(
                        finishActivityLocked(
                                p, Activity.RESULT_CANCELED, null, null, "move-affinity", false);
                                p, Activity.RESULT_CANCELED, null, "move-affinity", false);
                    }
                    }
                } else {
                } else {
                    if (taskInsertionPoint < 0) {
                    if (taskInsertionPoint < 0) {
@@ -3539,8 +3538,8 @@ class ActivityStack extends ConfigurationContainer {
                        if (targetNdx > 0) {
                        if (targetNdx > 0) {
                            ActivityRecord p = taskActivities.get(targetNdx - 1);
                            ActivityRecord p = taskActivities.get(targetNdx - 1);
                            if (p.intent.getComponent().equals(target.intent.getComponent())) {
                            if (p.intent.getComponent().equals(target.intent.getComponent())) {
                                finishActivityLocked(p, Activity.RESULT_CANCELED, null, null,
                                finishActivityLocked(p, Activity.RESULT_CANCELED, null, "replace",
                                        "replace", false);
                                        false);
                            }
                            }
                        }
                        }
                    }
                    }
@@ -3600,21 +3599,22 @@ class ActivityStack extends ConfigurationContainer {
        return taskTop;
        return taskTop;
    }
    }


    void sendActivityResultLocked(int callingUid, ActivityRecord r, String resultWho,
    void sendActivityResultLocked(int callingUid, ActivityRecord r,
            int requestCode, int resultCode, Intent resultData, NeededUriGrants resultGrants) {
            String resultWho, int requestCode, int resultCode, Intent data) {

        if (callingUid > 0) {
        if (callingUid > 0) {
            mService.mUgmInternal.grantUriPermissionUncheckedFromIntent(resultGrants,
            mService.mUgmInternal.grantUriPermissionFromIntent(callingUid, r.packageName,
                    r.getUriPermissionsLocked());
                    data, r.getUriPermissionsLocked(), r.mUserId);
        }
        }


        if (DEBUG_RESULTS) Slog.v(TAG, "Send activity result to " + r
        if (DEBUG_RESULTS) Slog.v(TAG, "Send activity result to " + r
                + " : who=" + resultWho + " req=" + requestCode
                + " : who=" + resultWho + " req=" + requestCode
                + " res=" + resultCode + " data=" + resultData);
                + " res=" + resultCode + " data=" + data);
        if (mResumedActivity == r && r.attachedToProcess()) {
        if (mResumedActivity == r && r.attachedToProcess()) {
            try {
            try {
                ArrayList<ResultInfo> list = new ArrayList<ResultInfo>();
                ArrayList<ResultInfo> list = new ArrayList<ResultInfo>();
                list.add(new ResultInfo(resultWho, requestCode,
                list.add(new ResultInfo(resultWho, requestCode,
                        resultCode, resultData));
                        resultCode, data));
                mService.getLifecycleManager().scheduleTransaction(r.app.getThread(), r.appToken,
                mService.getLifecycleManager().scheduleTransaction(r.app.getThread(), r.appToken,
                        ActivityResultItem.obtain(list));
                        ActivityResultItem.obtain(list));
                return;
                return;
@@ -3623,7 +3623,7 @@ class ActivityStack extends ConfigurationContainer {
            }
            }
        }
        }


        r.addResultLocked(null, resultWho, requestCode, resultCode, resultData);
        r.addResultLocked(null, resultWho, requestCode, resultCode, data);
    }
    }


    /** Returns true if the task is one of the task finishing on-top of the top running task. */
    /** Returns true if the task is one of the task finishing on-top of the top running task. */
@@ -3730,8 +3730,8 @@ class ActivityStack extends ConfigurationContainer {
            if (!r.finishing) {
            if (!r.finishing) {
                if (!shouldSleepActivities()) {
                if (!shouldSleepActivities()) {
                    if (DEBUG_STATES) Slog.d(TAG_STATES, "no-history finish of " + r);
                    if (DEBUG_STATES) Slog.d(TAG_STATES, "no-history finish of " + r);
                    if (requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED,
                    if (requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null,
                            null, null, "stop-no-history", false)) {
                            "stop-no-history", false)) {
                        // If {@link requestFinishActivityLocked} returns {@code true},
                        // If {@link requestFinishActivityLocked} returns {@code true},
                        // {@link adjustFocusedActivityStack} would have been already called.
                        // {@link adjustFocusedActivityStack} would have been already called.
                        r.resumeKeyDispatchingLocked();
                        r.resumeKeyDispatchingLocked();
@@ -3787,7 +3787,7 @@ class ActivityStack extends ConfigurationContainer {
     * some reason it is being left as-is.
     * some reason it is being left as-is.
     */
     */
    final boolean requestFinishActivityLocked(IBinder token, int resultCode,
    final boolean requestFinishActivityLocked(IBinder token, int resultCode,
            Intent resultData, NeededUriGrants resultGrants, String reason, boolean oomAdj) {
            Intent resultData, String reason, boolean oomAdj) {
        ActivityRecord r = isInStackLocked(token);
        ActivityRecord r = isInStackLocked(token);
        if (DEBUG_RESULTS || DEBUG_STATES) Slog.v(TAG_STATES,
        if (DEBUG_RESULTS || DEBUG_STATES) Slog.v(TAG_STATES,
                "Finishing activity token=" + token + " r="
                "Finishing activity token=" + token + " r="
@@ -3797,7 +3797,7 @@ class ActivityStack extends ConfigurationContainer {
            return false;
            return false;
        }
        }


        finishActivityLocked(r, resultCode, resultData, resultGrants, reason, oomAdj);
        finishActivityLocked(r, resultCode, resultData, reason, oomAdj);
        return true;
        return true;
    }
    }


@@ -3809,8 +3809,8 @@ class ActivityStack extends ConfigurationContainer {
                if (r.resultTo == self && r.requestCode == requestCode) {
                if (r.resultTo == self && r.requestCode == requestCode) {
                    if ((r.resultWho == null && resultWho == null) ||
                    if ((r.resultWho == null && resultWho == null) ||
                        (r.resultWho != null && r.resultWho.equals(resultWho))) {
                        (r.resultWho != null && r.resultWho.equals(resultWho))) {
                        finishActivityLocked(r, Activity.RESULT_CANCELED, null, null,
                        finishActivityLocked(r, Activity.RESULT_CANCELED, null, "request-sub",
                                "request-sub", false);
                                false);
                    }
                    }
                }
                }
            }
            }
@@ -3840,7 +3840,7 @@ class ActivityStack extends ConfigurationContainer {
        int activityNdx = task.mActivities.indexOf(r);
        int activityNdx = task.mActivities.indexOf(r);
        getDisplay().mDisplayContent.prepareAppTransition(
        getDisplay().mDisplayContent.prepareAppTransition(
                TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* alwaysKeepCurrent */);
                TRANSIT_CRASHING_ACTIVITY_CLOSE, false /* alwaysKeepCurrent */);
        finishActivityLocked(r, Activity.RESULT_CANCELED, null, null, reason, false);
        finishActivityLocked(r, Activity.RESULT_CANCELED, null, reason, false);
        finishedTask = task;
        finishedTask = task;
        // Also terminate any activities below it that aren't yet
        // Also terminate any activities below it that aren't yet
        // stopped, to avoid a situation where one will get
        // stopped, to avoid a situation where one will get
@@ -3861,7 +3861,7 @@ class ActivityStack extends ConfigurationContainer {
                if (!r.isActivityTypeHome() || mService.mHomeProcess != r.app) {
                if (!r.isActivityTypeHome() || mService.mHomeProcess != r.app) {
                    Slog.w(TAG, "  Force finishing activity "
                    Slog.w(TAG, "  Force finishing activity "
                            + r.intent.getComponent().flattenToShortString());
                            + r.intent.getComponent().flattenToShortString());
                    finishActivityLocked(r, Activity.RESULT_CANCELED, null, null, reason, false);
                    finishActivityLocked(r, Activity.RESULT_CANCELED, null, reason, false);
                }
                }
            }
            }
        }
        }
@@ -3877,8 +3877,8 @@ class ActivityStack extends ConfigurationContainer {
                for (int activityNdx = tr.mActivities.size() - 1; activityNdx >= 0; --activityNdx) {
                for (int activityNdx = tr.mActivities.size() - 1; activityNdx >= 0; --activityNdx) {
                    ActivityRecord r = tr.mActivities.get(activityNdx);
                    ActivityRecord r = tr.mActivities.get(activityNdx);
                    if (!r.finishing) {
                    if (!r.finishing) {
                        finishActivityLocked(r, Activity.RESULT_CANCELED, null, null,
                        finishActivityLocked(r, Activity.RESULT_CANCELED, null, "finish-voice",
                                "finish-voice", false);
                                false);
                        didOne = true;
                        didOne = true;
                    }
                    }
                }
                }
@@ -3914,14 +3914,12 @@ class ActivityStack extends ConfigurationContainer {
            if (!Objects.equals(cur.taskAffinity, r.taskAffinity)) {
            if (!Objects.equals(cur.taskAffinity, r.taskAffinity)) {
                break;
                break;
            }
            }
            finishActivityLocked(cur, Activity.RESULT_CANCELED, null, null,
            finishActivityLocked(cur, Activity.RESULT_CANCELED, null, "request-affinity", true);
                    "request-affinity", true);
        }
        }
        return true;
        return true;
    }
    }


    private void finishActivityResultsLocked(ActivityRecord r, int resultCode, Intent resultData,
    private void finishActivityResultsLocked(ActivityRecord r, int resultCode, Intent resultData) {
            NeededUriGrants resultGrants) {
        // send the result
        // send the result
        ActivityRecord resultTo = r.resultTo;
        ActivityRecord resultTo = r.resultTo;
        if (resultTo != null) {
        if (resultTo != null) {
@@ -3934,8 +3932,9 @@ class ActivityStack extends ConfigurationContainer {
                }
                }
            }
            }
            if (r.info.applicationInfo.uid > 0) {
            if (r.info.applicationInfo.uid > 0) {
                mService.mUgmInternal.grantUriPermissionUncheckedFromIntent(resultGrants,
                mService.mUgmInternal.grantUriPermissionFromIntent(r.info.applicationInfo.uid,
                        resultTo.getUriPermissionsLocked());
                        resultTo.packageName, resultData,
                        resultTo.getUriPermissionsLocked(), resultTo.mUserId);
            }
            }
            resultTo.addResultLocked(r, r.resultWho, r.requestCode, resultCode, resultData);
            resultTo.addResultLocked(r, r.resultWho, r.requestCode, resultCode, resultData);
            r.resultTo = null;
            r.resultTo = null;
@@ -3951,10 +3950,12 @@ class ActivityStack extends ConfigurationContainer {
        r.icicle = null;
        r.icicle = null;
    }
    }


    /**
     * See {@link #finishActivityLocked(ActivityRecord, int, Intent, String, boolean, boolean)}
     */
    final boolean finishActivityLocked(ActivityRecord r, int resultCode, Intent resultData,
    final boolean finishActivityLocked(ActivityRecord r, int resultCode, Intent resultData,
            NeededUriGrants resultGrants, String reason, boolean oomAdj) {
            String reason, boolean oomAdj) {
        return finishActivityLocked(r, resultCode, resultData, resultGrants, reason, oomAdj,
        return finishActivityLocked(r, resultCode, resultData, reason, oomAdj, !PAUSE_IMMEDIATELY);
                !PAUSE_IMMEDIATELY);
    }
    }


    /**
    /**
@@ -3962,7 +3963,7 @@ class ActivityStack extends ConfigurationContainer {
     * list, or false if it is still in the list and will be removed later.
     * list, or false if it is still in the list and will be removed later.
     */
     */
    final boolean finishActivityLocked(ActivityRecord r, int resultCode, Intent resultData,
    final boolean finishActivityLocked(ActivityRecord r, int resultCode, Intent resultData,
            NeededUriGrants resultGrants, String reason, boolean oomAdj, boolean pauseImmediately) {
            String reason, boolean oomAdj, boolean pauseImmediately) {
        if (r.finishing) {
        if (r.finishing) {
            Slog.w(TAG, "Duplicate finish request for " + r);
            Slog.w(TAG, "Duplicate finish request for " + r);
            return false;
            return false;
@@ -3992,7 +3993,7 @@ class ActivityStack extends ConfigurationContainer {


            adjustFocusedActivityStack(r, "finishActivity");
            adjustFocusedActivityStack(r, "finishActivity");


            finishActivityResultsLocked(r, resultCode, resultData, resultGrants);
            finishActivityResultsLocked(r, resultCode, resultData);


            final boolean endTask = index <= 0 && !task.isClearingToReuseTask();
            final boolean endTask = index <= 0 && !task.isClearingToReuseTask();
            final int transit = endTask ? TRANSIT_TASK_CLOSE : TRANSIT_ACTIVITY_CLOSE;
            final int transit = endTask ? TRANSIT_TASK_CLOSE : TRANSIT_ACTIVITY_CLOSE;
@@ -4225,9 +4226,8 @@ class ActivityStack extends ConfigurationContainer {
        return false;
        return false;
    }
    }


    final boolean navigateUpToLocked(ActivityRecord srec, Intent destIntent,
    final boolean navigateUpToLocked(ActivityRecord srec, Intent destIntent, int resultCode,
            NeededUriGrants destGrants, int resultCode, Intent resultData,
            Intent resultData) {
            NeededUriGrants resultGrants) {
        final TaskRecord task = srec.getTaskRecord();
        final TaskRecord task = srec.getTaskRecord();
        final ArrayList<ActivityRecord> activities = task.mActivities;
        final ArrayList<ActivityRecord> activities = task.mActivities;
        final int start = activities.indexOf(srec);
        final int start = activities.indexOf(srec);
@@ -4274,8 +4274,7 @@ class ActivityStack extends ConfigurationContainer {
        final long origId = Binder.clearCallingIdentity();
        final long origId = Binder.clearCallingIdentity();
        for (int i = start; i > finishTo; i--) {
        for (int i = start; i > finishTo; i--) {
            ActivityRecord r = activities.get(i);
            ActivityRecord r = activities.get(i);
            requestFinishActivityLocked(r.appToken, resultCode, resultData, resultGrants,
            requestFinishActivityLocked(r.appToken, resultCode, resultData, "navigate-up", true);
                    "navigate-up", true);
            // Only return the supplied result for the first activity finished
            // Only return the supplied result for the first activity finished
            resultCode = Activity.RESULT_CANCELED;
            resultCode = Activity.RESULT_CANCELED;
            resultData = null;
            resultData = null;
@@ -4289,7 +4288,7 @@ class ActivityStack extends ConfigurationContainer {
                    parentLaunchMode == ActivityInfo.LAUNCH_SINGLE_TOP ||
                    parentLaunchMode == ActivityInfo.LAUNCH_SINGLE_TOP ||
                    (destIntentFlags & Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0) {
                    (destIntentFlags & Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0) {
                parent.deliverNewIntentLocked(srec.info.applicationInfo.uid, destIntent,
                parent.deliverNewIntentLocked(srec.info.applicationInfo.uid, destIntent,
                        destGrants, srec.packageName);
                        srec.packageName);
            } else {
            } else {
                try {
                try {
                    ActivityInfo aInfo = AppGlobals.getPackageManager().getActivityInfo(
                    ActivityInfo aInfo = AppGlobals.getPackageManager().getActivityInfo(
@@ -4313,7 +4312,7 @@ class ActivityStack extends ConfigurationContainer {
                    foundParentInTask = false;
                    foundParentInTask = false;
                }
                }
                requestFinishActivityLocked(parent.appToken, resultCode,
                requestFinishActivityLocked(parent.appToken, resultCode,
                        resultData, resultGrants, "navigate-top", true);
                        resultData, "navigate-top", true);
            }
            }
        }
        }
        Binder.restoreCallingIdentity(origId);
        Binder.restoreCallingIdentity(origId);
@@ -4398,7 +4397,7 @@ class ActivityStack extends ConfigurationContainer {
    }
    }


    private void removeActivityFromHistoryLocked(ActivityRecord r, String reason) {
    private void removeActivityFromHistoryLocked(ActivityRecord r, String reason) {
        finishActivityResultsLocked(r, Activity.RESULT_CANCELED, null, null);
        finishActivityResultsLocked(r, Activity.RESULT_CANCELED, null);
        r.makeFinishingLocked();
        r.makeFinishingLocked();
        if (DEBUG_ADD_REMOVE) Slog.i(TAG_ADD_REMOVE,
        if (DEBUG_ADD_REMOVE) Slog.i(TAG_ADD_REMOVE,
                "Removing activity " + r + " from stack callers=" + Debug.getCallers(5));
                "Removing activity " + r + " from stack callers=" + Debug.getCallers(5));
@@ -5130,8 +5129,7 @@ class ActivityStack extends ConfigurationContainer {
            for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
            for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
                final ActivityRecord r = activities.get(activityNdx);
                final ActivityRecord r = activities.get(activityNdx);
                if ((r.info.flags&ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0) {
                if ((r.info.flags&ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0) {
                    finishActivityLocked(r, Activity.RESULT_CANCELED, null, null,
                    finishActivityLocked(r, Activity.RESULT_CANCELED, null, "close-sys", true);
                            "close-sys", true);
                }
                }
            }
            }
        }
        }
@@ -5175,8 +5173,8 @@ class ActivityStack extends ConfigurationContainer {
                    didSomething = true;
                    didSomething = true;
                    Slog.i(TAG, "  Force finishing activity " + r);
                    Slog.i(TAG, "  Force finishing activity " + r);
                    lastTask = r.getTaskRecord();
                    lastTask = r.getTaskRecord();
                    finishActivityLocked(r, Activity.RESULT_CANCELED, null, null,
                    finishActivityLocked(r, Activity.RESULT_CANCELED, null, "force-stop",
                            "force-stop", true);
                            true);
                }
                }
            }
            }
        }
        }
@@ -5230,8 +5228,8 @@ class ActivityStack extends ConfigurationContainer {
            final ArrayList<ActivityRecord> activities = mTaskHistory.get(top).mActivities;
            final ArrayList<ActivityRecord> activities = mTaskHistory.get(top).mActivities;
            int activityTop = activities.size() - 1;
            int activityTop = activities.size() - 1;
            if (activityTop >= 0) {
            if (activityTop >= 0) {
                finishActivityLocked(activities.get(activityTop), Activity.RESULT_CANCELED,
                finishActivityLocked(activities.get(activityTop), Activity.RESULT_CANCELED, null,
                        null, null, "unhandled-back", true);
                        "unhandled-back", true);
            }
            }
        }
        }
    }
    }
+10 −14
Original line number Original line Diff line number Diff line
@@ -140,7 +140,6 @@ import com.android.internal.util.function.pooled.PooledLambda;
import com.android.server.am.ActivityManagerService;
import com.android.server.am.ActivityManagerService;
import com.android.server.am.EventLogTags;
import com.android.server.am.EventLogTags;
import com.android.server.am.UserState;
import com.android.server.am.UserState;
import com.android.server.uri.NeededUriGrants;


import java.io.FileDescriptor;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.IOException;
@@ -404,17 +403,14 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        final int startFlags;
        final int startFlags;
        final ActivityStack stack;
        final ActivityStack stack;
        final WindowProcessController callerApp;
        final WindowProcessController callerApp;
        final NeededUriGrants neededGrants;


        PendingActivityLaunch(ActivityRecord r, ActivityRecord sourceRecord,
        PendingActivityLaunch(ActivityRecord _r, ActivityRecord _sourceRecord,
                int startFlags, ActivityStack stack, WindowProcessController callerApp,
                int _startFlags, ActivityStack _stack, WindowProcessController app) {
                NeededUriGrants neededGrants) {
            r = _r;
            this.r = r;
            sourceRecord = _sourceRecord;
            this.sourceRecord = sourceRecord;
            startFlags = _startFlags;
            this.startFlags = startFlags;
            stack = _stack;
            this.stack = stack;
            callerApp = app;
            this.callerApp = callerApp;
            this.neededGrants = neededGrants;
        }
        }


        void sendErrorResult(String message) {
        void sendErrorResult(String message) {
@@ -878,8 +874,8 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                    Slog.e(TAG, "Second failure launching "
                    Slog.e(TAG, "Second failure launching "
                            + r.intent.getComponent().flattenToShortString() + ", giving up", e);
                            + r.intent.getComponent().flattenToShortString() + ", giving up", e);
                    proc.appDied();
                    proc.appDied();
                    stack.requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED,
                    stack.requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null,
                            null, null, "2nd-crash", false);
                            "2nd-crash", false);
                    return false;
                    return false;
                }
                }


@@ -1024,7 +1020,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
            if (resultRecord != null) {
            if (resultRecord != null) {
                resultStack.sendActivityResultLocked(-1,
                resultStack.sendActivityResultLocked(-1,
                        resultRecord, resultWho, requestCode,
                        resultRecord, resultWho, requestCode,
                        Activity.RESULT_CANCELED, null, null);
                        Activity.RESULT_CANCELED, null);
            }
            }
            final String msg;
            final String msg;
            if (actionRestriction == ACTIVITY_RESTRICTION_PERMISSION) {
            if (actionRestriction == ACTIVITY_RESTRICTION_PERMISSION) {
Loading