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

Commit 16fec001 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Remove multiple starting windows within a transaction." into main

parents 6effb24a 72c4f72e
Loading
Loading
Loading
Loading
+28 −16
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.Transitions;

import java.util.ArrayList;

/**
 * Implementation to draw the starting window to an application, and remove the starting window
 * until the application displays its own window.
@@ -161,17 +163,20 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
            if (!hasPendingRemoval()) {
                return;
            }
            final WindowRecord r = findRecord(transition);
            if (r != null) {
            final ArrayList<WindowRecord> records = findRecords(transition);
            if (records != null) {
                startTransaction.addTransactionCommittedListener(mShellMainExecutor, () -> {
                    final WindowRecord wr = mWindowRecords.get(r.mTaskId);
                    for (int i = records.size() - 1; i >= 0; --i) {
                        final int taskId = records.get(i).mTaskId;
                        final WindowRecord wr = mWindowRecords.get(taskId);
                        if (wr == null) {
                            return;
                        }
                        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_REMOVE_STARTING_TRACKER,
                            "RSO:Transaction applied for task=%d", r.mTaskId);
                                "RSO:Transaction applied for task=%d", taskId);
                        wr.mTransactionApplied = true;
                        executeRemovalIfPossible(wr);
                    }
                });
                return;
            }
@@ -201,10 +206,13 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
                return;
            }
            // Ensure nothing left.
            final WindowRecord r = findRecord(transition);
            if (r != null) {
            final ArrayList<WindowRecord> records = findRecords(transition);
            if (records != null) {
                for (int i = records.size() - 1; i >= 0; --i) {
                    final WindowRecord r = records.get(i);
                    r.mTransactionApplied = true;
                    executeRemovalIfPossible(r);
                }
            } else {
                uncertainTrackComplete(transition);
            }
@@ -225,14 +233,18 @@ public class StartingWindowController implements RemoteCallable<StartingWindowCo
            return mWindowRecords.size() != 0;
        }

        WindowRecord findRecord(IBinder transition) {
        ArrayList<WindowRecord> findRecords(IBinder transition) {
            ArrayList<WindowRecord> records = null;
            for (int i = mWindowRecords.size() - 1; i >= 0; --i) {
                final WindowRecord record = mWindowRecords.valueAt(i);
                if (record.mTransition == transition) {
                    return record;
                    if (records == null) {
                        records = new ArrayList<>();
                    }
                    records.add(record);
                }
            }
            return null;
            return records;
        }

        void requestRemoval(int taskId, StartingWindowRemovalInfo removalInfo) {