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

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

Merge "Ensure no starting window leak in WMShell before adding." into sc-dev

parents 947270ef 5cdbeb1a
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -347,8 +347,13 @@ public class StartingSurfaceDrawer {
    void makeTaskSnapshotWindow(StartingWindowInfo startingWindowInfo, IBinder appToken,
    void makeTaskSnapshotWindow(StartingWindowInfo startingWindowInfo, IBinder appToken,
            TaskSnapshot snapshot) {
            TaskSnapshot snapshot) {
        final int taskId = startingWindowInfo.taskInfo.taskId;
        final int taskId = startingWindowInfo.taskInfo.taskId;
        // Remove any existing starting window for this task before adding.
        removeWindowNoAnimate(taskId);
        final TaskSnapshotWindow surface = TaskSnapshotWindow.create(startingWindowInfo, appToken,
        final TaskSnapshotWindow surface = TaskSnapshotWindow.create(startingWindowInfo, appToken,
                snapshot, mSplashScreenExecutor, () -> removeWindowNoAnimate(taskId));
                snapshot, mSplashScreenExecutor, () -> removeWindowNoAnimate(taskId));
        if (surface == null) {
            return;
        }
        final StartingWindowRecord tView = new StartingWindowRecord(appToken,
        final StartingWindowRecord tView = new StartingWindowRecord(appToken,
                null/* decorView */, surface);
                null/* decorView */, surface);
        mStartingWindowRecords.put(taskId, tView);
        mStartingWindowRecords.put(taskId, tView);
+30 −31
Original line number Original line Diff line number Diff line
@@ -45,6 +45,7 @@ import static com.android.internal.policy.DecorView.STATUS_BAR_COLOR_VIEW_ATTRIB
import static com.android.internal.policy.DecorView.getNavigationBarRect;
import static com.android.internal.policy.DecorView.getNavigationBarRect;


import android.annotation.BinderThread;
import android.annotation.BinderThread;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.ActivityManager.TaskDescription;
import android.app.ActivityManager.TaskDescription;
@@ -141,7 +142,8 @@ public class TaskSnapshotWindow {
    private final float[] mTmpFloat9 = new float[9];
    private final float[] mTmpFloat9 = new float[9];


    static TaskSnapshotWindow create(StartingWindowInfo info, IBinder appToken,
    static TaskSnapshotWindow create(StartingWindowInfo info, IBinder appToken,
            TaskSnapshot snapshot, ShellExecutor mainExecutor, Runnable clearWindowHandler) {
            TaskSnapshot snapshot, ShellExecutor splashScreenExecutor,
            @NonNull Runnable clearWindowHandler) {
        final ActivityManager.RunningTaskInfo runningTaskInfo = info.taskInfo;
        final ActivityManager.RunningTaskInfo runningTaskInfo = info.taskInfo;
        final int taskId = runningTaskInfo.taskId;
        final int taskId = runningTaskInfo.taskId;
        if (DEBUG) {
        if (DEBUG) {
@@ -208,12 +210,12 @@ public class TaskSnapshotWindow {
        final TaskSnapshotWindow snapshotSurface = new TaskSnapshotWindow(
        final TaskSnapshotWindow snapshotSurface = new TaskSnapshotWindow(
                surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, appearance,
                surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, appearance,
                windowFlags, windowPrivateFlags, taskBounds, orientation,
                windowFlags, windowPrivateFlags, taskBounds, orientation,
                topWindowInsetsState, clearWindowHandler, mainExecutor);
                topWindowInsetsState, clearWindowHandler, splashScreenExecutor);
        final Window window = snapshotSurface.mWindow;
        final Window window = snapshotSurface.mWindow;


        final InsetsState mTmpInsetsState = new InsetsState();
        final InsetsState mTmpInsetsState = new InsetsState();
        final InputChannel tmpInputChannel = new InputChannel();
        final InputChannel tmpInputChannel = new InputChannel();
        mainExecutor.execute(() -> {

        try {
        try {
            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "TaskSnapshot#addToDisplay");
            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "TaskSnapshot#addToDisplay");
            final int res = session.addToDisplay(window, layoutParams, View.GONE, displayId,
            final int res = session.addToDisplay(window, layoutParams, View.GONE, displayId,
@@ -221,7 +223,7 @@ public class TaskSnapshotWindow {
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
            if (res < 0) {
            if (res < 0) {
                Slog.w(TAG, "Failed to add snapshot starting window res=" + res);
                Slog.w(TAG, "Failed to add snapshot starting window res=" + res);
                    return;
                return null;
            }
            }
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            snapshotSurface.clearWindowSynced();
            snapshotSurface.clearWindowSynced();
@@ -240,7 +242,6 @@ public class TaskSnapshotWindow {
        final Rect systemBarInsets = getSystemBarInsets(tmpFrames.frame, topWindowInsetsState);
        final Rect systemBarInsets = getSystemBarInsets(tmpFrames.frame, topWindowInsetsState);
        snapshotSurface.setFrames(tmpFrames.frame, systemBarInsets);
        snapshotSurface.setFrames(tmpFrames.frame, systemBarInsets);
        snapshotSurface.drawSnapshot();
        snapshotSurface.drawSnapshot();
        });
        return snapshotSurface;
        return snapshotSurface;
    }
    }


@@ -469,9 +470,7 @@ public class TaskSnapshotWindow {
     * Clear window from drawer, must be post on main executor.
     * Clear window from drawer, must be post on main executor.
     */
     */
    private void clearWindowSynced() {
    private void clearWindowSynced() {
        if (mClearWindowHandler != null) {
        mSplashScreenExecutor.executeDelayed(mClearWindowHandler, 0);
            mClearWindowHandler.run();
        }
    }
    }


    private void reportDrawn() {
    private void reportDrawn() {