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

Commit ff4494a8 authored by Louis Chang's avatar Louis Chang
Browse files

Resets the activity translucent state if app died

Activity was temporary set to translucent while being started
with scene transition animation. Somehow, the app killed itself
on purpose. Although, the process restarted and the activity
was relaunched, the activity remained to be translucent.

This is possible in two cases:
#1, the convert-to-translucent activity is waiting for the
    activities below to be drawn, but app died.
#2, the activities below are drawn and waiting for the client
    to perform the transition, but app died.

Bug: 325150975
Test: kill app when activity started with scene transition
Change-Id: I0a545a0d10bae607145b4ea52117c7134d91b9ed
parent 3559a202
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -3272,8 +3272,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        mOccludesParent = occludesParent;
        setMainWindowOpaque(occludesParent);
        if (changed && task != null && !occludesParent) {
        if (changed && task != null) {
            if (!occludesParent) {
                getRootTask().convertActivityToTranslucent(this);
            } else {
                getRootTask().convertActivityFromTranslucent(this);
            }
        }
        // Always ensure visibility if this activity doesn't occlude parent, so the
        // {@link #returningOptions} of the activity under this one can be applied in
@@ -4266,6 +4270,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        getTaskFragment().cleanUpActivityReferences(this);
        clearLastParentBeforePip();
        // Abort and reset state if the scence transition is playing.
        final Task rootTask = getRootTask();
        if (rootTask != null) {
            rootTask.abortTranslucentActivityWaiting(this);
        }
        // Clean up the splash screen if it was still displayed.
        cleanUpSplashScreen();
+34 −0
Original line number Diff line number Diff line
@@ -299,6 +299,10 @@ class Task extends TaskFragment {
    ActivityRecord mTranslucentActivityWaiting = null;
    ArrayList<ActivityRecord> mUndrawnActivitiesBelowTopTranslucent = new ArrayList<>();

    // The topmost Activity that was converted to translucent for scene transition, which should
    // be converted from translucent once the transition is completed, or the app died.
    private ActivityRecord mPendingConvertFromTranslucentActivity = null;

    /**
     * Set when we know we are going to be calling updateConfiguration()
     * soon, so want to skip intermediate config checks.
@@ -5037,6 +5041,27 @@ class Task extends TaskFragment {
        }
    }

    void abortTranslucentActivityWaiting(@NonNull ActivityRecord r) {
        if (r != mTranslucentActivityWaiting && r != mPendingConvertFromTranslucentActivity) {
            return;
        }

        if (mTranslucentActivityWaiting != null) {
            if (!mTranslucentActivityWaiting.finishing) {
                mTranslucentActivityWaiting.setOccludesParent(true);
            }
            mTranslucentActivityWaiting = null;
        }
        if (mPendingConvertFromTranslucentActivity != null) {
            if (!mPendingConvertFromTranslucentActivity.finishing) {
                mPendingConvertFromTranslucentActivity.setOccludesParent(true);
            }
            mPendingConvertFromTranslucentActivity = null;
        }
        mUndrawnActivitiesBelowTopTranslucent.clear();
        mHandler.removeMessages(TRANSLUCENT_TIMEOUT_MSG);
    }

    void checkTranslucentActivityWaiting(ActivityRecord top) {
        if (mTranslucentActivityWaiting != top) {
            mUndrawnActivitiesBelowTopTranslucent.clear();
@@ -5051,10 +5076,19 @@ class Task extends TaskFragment {

    void convertActivityToTranslucent(ActivityRecord r) {
        mTranslucentActivityWaiting = r;
        mPendingConvertFromTranslucentActivity = r;
        mUndrawnActivitiesBelowTopTranslucent.clear();
        mHandler.sendEmptyMessageDelayed(TRANSLUCENT_TIMEOUT_MSG, TRANSLUCENT_CONVERSION_TIMEOUT);
    }

    void convertActivityFromTranslucent(ActivityRecord r) {
        if (r != mPendingConvertFromTranslucentActivity) {
            Slog.e(TAG, "convertFromTranslucent expects " + mPendingConvertFromTranslucentActivity
                    + " but is " + r);
        }
        mPendingConvertFromTranslucentActivity = null;
    }

    /**
     * Called as activities below the top translucent activity are redrawn. When the last one is
     * redrawn notify the top activity by calling