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

Commit 866120bb authored by wilsonshih's avatar wilsonshih Committed by Wei Sheng Shih
Browse files

Fix SnapshotRecord being overwritten when requesting a new one.

Because the key of StartingWindowRecordManager is taskId, there can
always add/remove activity snapshot with the same key. So before add a
new record, remove previous starting window record immediately.

Bug: 328563338
Test: trigger cross-activity animation aggressively
Change-Id: I9122d5046a48ad9f7b5987686dcf2d42617686d4
parent bc194cb7
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.window.StartingWindowRemovalInfo.DEFER_MODE_NORMAL;
import static android.window.StartingWindowRemovalInfo.DEFER_MODE_ROTATION;

import android.annotation.CallSuper;
import android.annotation.NonNull;
import android.app.TaskInfo;
import android.app.WindowConfiguration;
import android.content.Context;
@@ -306,7 +307,7 @@ public class StartingSurfaceDrawer {
        @CallSuper
        protected void removeImmediately() {
            mRemoveExecutor.removeCallbacks(mScheduledRunnable);
            mRecordManager.onRecordRemoved(mTaskId);
            mRecordManager.onRecordRemoved(this, mTaskId);
        }
    }

@@ -327,6 +328,11 @@ public class StartingSurfaceDrawer {
        }

        void addRecord(int taskId, StartingWindowRecord record) {
            final StartingWindowRecord original = mStartingWindowRecords.get(taskId);
            if (original != null) {
                mTmpRemovalInfo.taskId = taskId;
                original.removeIfPossible(mTmpRemovalInfo, true /* immediately */);
            }
            mStartingWindowRecords.put(taskId, record);
        }

@@ -346,9 +352,12 @@ public class StartingSurfaceDrawer {
            removeWindow(mTmpRemovalInfo, true/* immediately */);
        }

        void onRecordRemoved(int taskId) {
        void onRecordRemoved(@NonNull StartingWindowRecord record, int taskId) {
            final StartingWindowRecord currentRecord = mStartingWindowRecords.get(taskId);
            if (currentRecord == record) {
                mStartingWindowRecords.remove(taskId);
            }
        }

        StartingWindowRecord getRecord(int taskId) {
            return mStartingWindowRecords.get(taskId);