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

Commit 742313e4 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Do not capture task snapshot with fixed rotated activity

Because the rotation of activity and task are different, The
information of snapshot may be inconsistent. And since it is a
temporal state, in most cases the snapshot is available after
the fixed rotation is cleared. This fixes a non-rotated snapshot
is shown on a rotated activity when repeating launch and swipe
to home quickly.

Also the fixed rotation launching app should not be cleared if
there is pending rotation, otherwise it is too early that the
display is still in old rotation. This fixes flickering when
switching between activities in different rotation from quickstep.

Bug: 155862858
Test: atest TaskSnapshotControllerTest#testPrepareTaskSnapshot
      ActivityRecordTests#testActivityOnCancelFixedRotationTransform
Change-Id: I8e30e87ea4aad907c4ad4338b91fcff3078380ad
parent a08db2de
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1511,6 +1511,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            sendNewConfiguration();
            return;
        }
        if (mDisplayRotation.isWaitingForRemoteRotation()) {
            // There is pending rotation change to apply.
            return;
        }
        // The orientation of display is not changed.
        clearFixedRotationLaunchingApp();
    }
+7 −0
Original line number Diff line number Diff line
@@ -297,6 +297,13 @@ class TaskSnapshotController {
            Slog.w(TAG_WM, "Failed to take screenshot. No main window for " + task);
            return false;
        }
        if (activity.hasFixedRotationTransform()) {
            if (DEBUG_SCREENSHOT) {
                Slog.i(TAG_WM, "Skip taking screenshot. App has fixed rotation " + activity);
            }
            // The activity is in a temporal state that it has different rotation than the task.
            return false;
        }

        builder.setIsRealSnapshot(true);
        builder.setId(System.currentTimeMillis());
+4 −0
Original line number Diff line number Diff line
@@ -1404,6 +1404,10 @@ public class ActivityRecordTests extends ActivityTestsBase {

        assertTrue(displayRotation.isRotatingSeamlessly());

        // The launching rotated app should not be cleared when waiting for remote rotation.
        display.continueUpdateOrientationForDiffOrienLaunchingApp();
        assertNotNull(display.mFixedRotationLaunchingApp);

        // Simulate the rotation has been updated to previous one, e.g. sensor updates before the
        // remote rotation is completed.
        doReturn(originalRotation).when(displayRotation).rotationForOrientation(
+10 −2
Original line number Diff line number Diff line
@@ -192,10 +192,18 @@ public class TaskSnapshotControllerTest extends WindowTestsBase {

        final ActivityManager.TaskSnapshot.Builder builder =
                new ActivityManager.TaskSnapshot.Builder();
        mWm.mTaskSnapshotController.prepareTaskSnapshot(mAppWindow.mActivityRecord.getTask(),
                PixelFormat.UNKNOWN, builder);
        boolean success = mWm.mTaskSnapshotController.prepareTaskSnapshot(
                mAppWindow.mActivityRecord.getTask(), PixelFormat.UNKNOWN, builder);

        assertTrue(success);
        // The pixel format should be selected automatically.
        assertNotEquals(PixelFormat.UNKNOWN, builder.getPixelFormat());

        // Snapshot should not be taken while the rotation of activity and task are different.
        doReturn(true).when(mAppWindow.mActivityRecord).hasFixedRotationTransform();
        success = mWm.mTaskSnapshotController.prepareTaskSnapshot(
                mAppWindow.mActivityRecord.getTask(), PixelFormat.UNKNOWN, builder);

        assertFalse(success);
    }
}