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

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

Merge "Validate the surface of snapshot window before draw." into main

parents 5d0f9ac2 aeca005a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -146,6 +146,11 @@ public class TaskSnapshotWindow {
            Slog.w(TAG, "Failed to relayout snapshot starting window");
            return null;
        }
        if (!surfaceControl.isValid()) {
            snapshotSurface.clearWindowSynced();
            Slog.w(TAG, "Unable to draw snapshot, no valid surface");
            return null;
        }

        SnapshotDrawerUtils.drawSnapshotOnSurface(info, layoutParams, surfaceControl, snapshot,
                info.taskBounds, topWindowInsetsState, true /* releaseAfterDraw */);
+5 −15
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import static com.android.wm.shell.startingsurface.SplashscreenContentDrawer.MIN
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
@@ -56,12 +55,11 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.UserHandle;
import android.testing.TestableContext;
import android.view.IWindowSession;
import android.view.InsetsState;
import android.view.Surface;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.WindowMetrics;
import android.window.SnapshotDrawerUtils;
import android.window.StartingWindowInfo;
import android.window.StartingWindowRemovalInfo;
import android.window.TaskSnapshot;
@@ -220,18 +218,10 @@ public class StartingSurfaceDrawerTests extends ShellTestCase {
                createWindowInfo(taskId, android.R.style.Theme, mBinder);
        TaskSnapshot snapshot = createTaskSnapshot(100, 100, new Point(100, 100),
                new Rect(0, 0, 0, 50), true /* hasImeSurface */);
        final IWindowSession session = WindowManagerGlobal.getWindowSession();
        spyOn(session);
        doReturn(WindowManagerGlobal.ADD_OKAY).when(session).addToDisplay(
                any() /* window */, any() /* attrs */,
                anyInt() /* viewVisibility */, anyInt() /* displayId */,
                anyInt() /* requestedVisibleTypes */, any() /* outInputChannel */,
                any() /* outInsetsState */, any() /* outActiveControls */,
                any() /* outAttachedFrame */, any() /* outSizeCompatScale */);
        TaskSnapshotWindow mockSnapshotWindow = TaskSnapshotWindow.create(windowInfo,
                mBinder,
                snapshot, mTestExecutor, () -> {
                });
        final TaskSnapshotWindow mockSnapshotWindow = new TaskSnapshotWindow(
                snapshot, SnapshotDrawerUtils.getOrCreateTaskDescription(windowInfo.taskInfo),
                snapshot.getOrientation(),
                () -> {}, mTestExecutor);
        spyOn(mockSnapshotWindow);
        try (AutoCloseable mockTaskSnapshotSession = new AutoCloseable() {
            MockitoSession mockSession = mockitoSession()