Loading libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingWindowController.java +7 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,13 @@ public class StartingWindowController { } return false; } if (!snapshot.getTopActivityComponent().equals(windowInfo.taskInfo.topActivity)) { if (DEBUG_SPLASH_SCREEN || DEBUG_TASK_SNAPSHOT) { Slog.d(TAG, "isSnapshotCompatible obsoleted snapshot " + windowInfo.taskInfo.topActivity); } return false; } final int taskRotation = windowInfo.taskInfo.configuration .windowConfiguration.getRotation(); Loading services/core/java/com/android/server/wm/ActivityRecord.java +4 −0 Original line number Diff line number Diff line Loading @@ -2114,6 +2114,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (snapshot == null) { return false; } if (!snapshot.getTopActivityComponent().equals(mActivityComponent)) { // Obsoleted snapshot. return false; } final int rotation = mDisplayContent.rotationForActivityInDifferentOrientation(this); final int targetRotation = rotation != ROTATION_UNDEFINED // The display may rotate according to the orientation of this activity. Loading services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +21 −0 Original line number Diff line number Diff line Loading @@ -1687,6 +1687,7 @@ public class ActivityRecordTests extends WindowTestsBase { public void testIsSnapshotCompatible() { final ActivityRecord activity = createActivityWithTask(); final TaskSnapshot snapshot = new TaskSnapshotPersisterTestBase.TaskSnapshotBuilder() .setTopActivityComponent(activity.mActivityComponent) .setRotation(activity.getWindowConfiguration().getRotation()) .build(); Loading @@ -1697,6 +1698,26 @@ public class ActivityRecordTests extends WindowTestsBase { assertFalse(activity.isSnapshotCompatible(snapshot)); } /** * Test that the snapshot should be obsoleted if the top activity changed. */ @Test public void testIsSnapshotCompatibleTopActivityChanged() { final ActivityRecord activity = createActivityWithTask(); final ActivityRecord secondActivity = new ActivityBuilder(mAtm) .setTask(activity.getTask()) .setOnTop(true) .build(); final TaskSnapshot snapshot = new TaskSnapshotPersisterTestBase.TaskSnapshotBuilder() .setTopActivityComponent(secondActivity.mActivityComponent) .build(); assertTrue(secondActivity.isSnapshotCompatible(snapshot)); // Emulate the top activity changed. assertFalse(activity.isSnapshotCompatible(snapshot)); } @Test public void testFixedRotationSnapshotStartingWindow() { final ActivityRecord activity = createActivityWithTask(); Loading services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java +8 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.window.TaskSnapshot; import android.content.ComponentName; import android.content.ContextWrapper; import android.content.res.Resources; Loading @@ -42,6 +41,7 @@ import android.graphics.Rect; import android.hardware.HardwareBuffer; import android.os.UserManager; import android.view.Surface; import android.window.TaskSnapshot; import com.android.server.LocalServices; import com.android.server.pm.UserManagerInternal; Loading Loading @@ -154,10 +154,16 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase { private int mWindowingMode = WINDOWING_MODE_FULLSCREEN; private int mSystemUiVisibility = 0; private int mRotation = Surface.ROTATION_0; private ComponentName mTopActivityComponent = new ComponentName("", ""); TaskSnapshotBuilder() { } TaskSnapshotBuilder setTopActivityComponent(ComponentName topActivityComponent) { mTopActivityComponent = topActivityComponent; return this; } TaskSnapshotBuilder setScaleFraction(float scale) { mScaleFraction = scale; return this; Loading Loading @@ -199,7 +205,7 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase { Canvas c = buffer.lockCanvas(); c.drawColor(Color.RED); buffer.unlockCanvasAndPost(c); return new TaskSnapshot(MOCK_SNAPSHOT_ID, new ComponentName("", ""), return new TaskSnapshot(MOCK_SNAPSHOT_ID, mTopActivityComponent, HardwareBuffer.createFromGraphicBuffer(buffer), ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT, mRotation, taskSize, TEST_INSETS, Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingWindowController.java +7 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,13 @@ public class StartingWindowController { } return false; } if (!snapshot.getTopActivityComponent().equals(windowInfo.taskInfo.topActivity)) { if (DEBUG_SPLASH_SCREEN || DEBUG_TASK_SNAPSHOT) { Slog.d(TAG, "isSnapshotCompatible obsoleted snapshot " + windowInfo.taskInfo.topActivity); } return false; } final int taskRotation = windowInfo.taskInfo.configuration .windowConfiguration.getRotation(); Loading
services/core/java/com/android/server/wm/ActivityRecord.java +4 −0 Original line number Diff line number Diff line Loading @@ -2114,6 +2114,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (snapshot == null) { return false; } if (!snapshot.getTopActivityComponent().equals(mActivityComponent)) { // Obsoleted snapshot. return false; } final int rotation = mDisplayContent.rotationForActivityInDifferentOrientation(this); final int targetRotation = rotation != ROTATION_UNDEFINED // The display may rotate according to the orientation of this activity. Loading
services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +21 −0 Original line number Diff line number Diff line Loading @@ -1687,6 +1687,7 @@ public class ActivityRecordTests extends WindowTestsBase { public void testIsSnapshotCompatible() { final ActivityRecord activity = createActivityWithTask(); final TaskSnapshot snapshot = new TaskSnapshotPersisterTestBase.TaskSnapshotBuilder() .setTopActivityComponent(activity.mActivityComponent) .setRotation(activity.getWindowConfiguration().getRotation()) .build(); Loading @@ -1697,6 +1698,26 @@ public class ActivityRecordTests extends WindowTestsBase { assertFalse(activity.isSnapshotCompatible(snapshot)); } /** * Test that the snapshot should be obsoleted if the top activity changed. */ @Test public void testIsSnapshotCompatibleTopActivityChanged() { final ActivityRecord activity = createActivityWithTask(); final ActivityRecord secondActivity = new ActivityBuilder(mAtm) .setTask(activity.getTask()) .setOnTop(true) .build(); final TaskSnapshot snapshot = new TaskSnapshotPersisterTestBase.TaskSnapshotBuilder() .setTopActivityComponent(secondActivity.mActivityComponent) .build(); assertTrue(secondActivity.isSnapshotCompatible(snapshot)); // Emulate the top activity changed. assertFalse(activity.isSnapshotCompatible(snapshot)); } @Test public void testFixedRotationSnapshotStartingWindow() { final ActivityRecord activity = createActivityWithTask(); Loading
services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java +8 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.window.TaskSnapshot; import android.content.ComponentName; import android.content.ContextWrapper; import android.content.res.Resources; Loading @@ -42,6 +41,7 @@ import android.graphics.Rect; import android.hardware.HardwareBuffer; import android.os.UserManager; import android.view.Surface; import android.window.TaskSnapshot; import com.android.server.LocalServices; import com.android.server.pm.UserManagerInternal; Loading Loading @@ -154,10 +154,16 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase { private int mWindowingMode = WINDOWING_MODE_FULLSCREEN; private int mSystemUiVisibility = 0; private int mRotation = Surface.ROTATION_0; private ComponentName mTopActivityComponent = new ComponentName("", ""); TaskSnapshotBuilder() { } TaskSnapshotBuilder setTopActivityComponent(ComponentName topActivityComponent) { mTopActivityComponent = topActivityComponent; return this; } TaskSnapshotBuilder setScaleFraction(float scale) { mScaleFraction = scale; return this; Loading Loading @@ -199,7 +205,7 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase { Canvas c = buffer.lockCanvas(); c.drawColor(Color.RED); buffer.unlockCanvasAndPost(c); return new TaskSnapshot(MOCK_SNAPSHOT_ID, new ComponentName("", ""), return new TaskSnapshot(MOCK_SNAPSHOT_ID, mTopActivityComponent, HardwareBuffer.createFromGraphicBuffer(buffer), ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT, mRotation, taskSize, TEST_INSETS, Loading