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

Commit 6ba042b5 authored by George Mount's avatar George Mount
Browse files

Make returning ActivityOptions part of ActivityRecord.

Bug 16626030

Getting the timing correct for when to clear returning activity options
was difficult when Activities can be destroyed and recreated. Moving
the returning ActivityOptions to the ActivityRecord forces the
ActivityOptions to only apply to the correct Activity.

Change-Id: Ib5400b157eb741ae484aae0cc83172a3db637a3e
parent c50ffa67
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -9559,13 +9559,17 @@ public final class ActivityManagerService extends ActivityManagerNative
                if (r == null) {
                    return false;
                }
                int index = r.task.mActivities.lastIndexOf(r);
                if (index > 0) {
                    ActivityRecord under = r.task.mActivities.get(index - 1);
                    under.returningOptions = options;
                }
                if (r.changeWindowTranslucency(false)) {
                    r.task.stack.convertToTranslucent(r, options);
                    r.task.stack.convertToTranslucent(r);
                    mWindowManager.setAppFullscreen(token, false);
                    mStackSupervisor.ensureActivitiesVisibleLocked(null, 0);
                    return true;
                } else {
                    r.task.stack.mReturningActivityOptions = options;
                    mStackSupervisor.ensureActivitiesVisibleLocked(null, 0);
                    return false;
                }
+1 −0
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@ final class ActivityRecord {
    HashSet<WeakReference<PendingIntentRecord>> pendingResults; // all pending intents for this act
    ArrayList<Intent> newIntents; // any pending new intents for single-top mode
    ActivityOptions pendingOptions; // most recently given options
    ActivityOptions returningOptions; // options that are coming back via convertToTranslucent
    HashSet<ConnectionRecord> connections; // All ConnectionRecord we hold
    UriPermissionOwner uriPermissions; // current special URI access perms.
    ProcessRecord app;      // if non-null, hosting application
+6 −11
Original line number Diff line number Diff line
@@ -211,9 +211,6 @@ final class ActivityStack {
    ActivityRecord mTranslucentActivityWaiting = null;
    private ArrayList<ActivityRecord> mUndrawnActivitiesBelowTopTranslucent =
            new ArrayList<ActivityRecord>();
    // Options passed from the caller of the convertToTranslucent to the activity that will
    // appear below it.
    ActivityOptions mReturningActivityOptions = null;

    /**
     * Set when we know we are going to be calling updateConfiguration()
@@ -1089,7 +1086,7 @@ final class ActivityStack {
        if (next == mLastScreenshotActivity) {
            invalidateLastScreenshot();
        }
        mReturningActivityOptions = null;
        next.returningOptions = null;
    }

    private void setVisibile(ActivityRecord r, boolean visible) {
@@ -1219,10 +1216,9 @@ final class ActivityStack {
                        if (DEBUG_VISBILITY) Slog.v(TAG, "Skipping: already visible at " + r);
                        r.stopFreezingScreenLocked(false);
                        try {
                            if (mReturningActivityOptions != null && r == top && activityNdx > 0) {
                                ActivityRecord under = activities.get(activityNdx - 1);
                                under.app.thread.scheduleOnNewActivityOptions(under.appToken,
                                        mReturningActivityOptions);
                            if (r.returningOptions != null) {
                                r.app.thread.scheduleOnNewActivityOptions(r.appToken,
                                        r.returningOptions);
                            }
                        } catch(RemoteException e) {
                        }
@@ -1237,7 +1233,7 @@ final class ActivityStack {
                                    TAG, "Making visible and scheduling visibility: " + r);
                            try {
                                if (mTranslucentActivityWaiting != null) {
                                    r.updateOptionsLocked(mReturningActivityOptions);
                                    r.updateOptionsLocked(r.returningOptions);
                                    mUndrawnActivitiesBelowTopTranslucent.add(r);
                                }
                                setVisibile(r, true);
@@ -1325,10 +1321,9 @@ final class ActivityStack {
        }
    }

    void convertToTranslucent(ActivityRecord r, ActivityOptions options) {
    void convertToTranslucent(ActivityRecord r) {
        mTranslucentActivityWaiting = r;
        mUndrawnActivitiesBelowTopTranslucent.clear();
        mReturningActivityOptions = options;
        mHandler.sendEmptyMessageDelayed(TRANSLUCENT_TIMEOUT_MSG, TRANSLUCENT_CONVERSION_TIMEOUT);
    }