summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/ActivityManager.java26
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java4
-rw-r--r--proto/src/task_snapshot.proto1
-rw-r--r--services/core/java/com/android/server/wm/TaskSnapshotController.java4
-rw-r--r--services/core/java/com/android/server/wm/TaskSnapshotLoader.java4
-rw-r--r--services/core/java/com/android/server/wm/TaskSnapshotPersister.java1
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterLoaderTest.java17
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java10
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java4
9 files changed, 64 insertions, 7 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index f7c4d96d0d40..e0a4ae287408 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -73,6 +73,7 @@ import android.util.DisplayMetrics;
import android.util.Singleton;
import android.util.Size;
import android.view.IWindowContainer;
+import android.view.Surface;
import com.android.internal.app.LocalePicker;
import com.android.internal.app.procstats.ProcessStats;
@@ -1928,7 +1929,12 @@ public class ActivityManager {
// Top activity in task when snapshot was taken
private final ComponentName mTopActivityComponent;
private final GraphicBuffer mSnapshot;
+ /** Indicates whether task was in landscape or portrait */
+ @Configuration.Orientation
private final int mOrientation;
+ /** See {@link android.view.Surface.Rotation} */
+ @Surface.Rotation
+ private int mRotation;
private final Rect mContentInsets;
// Whether this snapshot is a down-sampled version of the full resolution, used mainly for
// low-ram devices
@@ -1945,7 +1951,7 @@ public class ActivityManager {
public TaskSnapshot(long id,
@NonNull ComponentName topActivityComponent, GraphicBuffer snapshot,
- @NonNull ColorSpace colorSpace, int orientation, Rect contentInsets,
+ @NonNull ColorSpace colorSpace, int orientation, int rotation, Rect contentInsets,
boolean reducedResolution, float scale, boolean isRealSnapshot, int windowingMode,
int systemUiVisibility, boolean isTranslucent) {
mId = id;
@@ -1954,6 +1960,7 @@ public class ActivityManager {
mColorSpace = colorSpace.getId() < 0
? ColorSpace.get(ColorSpace.Named.SRGB) : colorSpace;
mOrientation = orientation;
+ mRotation = rotation;
mContentInsets = new Rect(contentInsets);
mReducedResolution = reducedResolution;
mScale = scale;
@@ -1972,6 +1979,7 @@ public class ActivityManager {
? ColorSpace.get(ColorSpace.Named.values()[colorSpaceId])
: ColorSpace.get(ColorSpace.Named.SRGB);
mOrientation = source.readInt();
+ mRotation = source.readInt();
mContentInsets = source.readParcelable(null /* classLoader */);
mReducedResolution = source.readBoolean();
mScale = source.readFloat();
@@ -2019,6 +2027,13 @@ public class ActivityManager {
}
/**
+ * @return The screen rotation the screenshot was taken in.
+ */
+ public int getRotation() {
+ return mRotation;
+ }
+
+ /**
* @return The system/content insets on the snapshot. These can be clipped off in order to
* remove any areas behind system bars in the snapshot.
*/
@@ -2087,6 +2102,7 @@ public class ActivityManager {
dest.writeParcelable(mSnapshot, 0);
dest.writeInt(mColorSpace.getId());
dest.writeInt(mOrientation);
+ dest.writeInt(mRotation);
dest.writeParcelable(mContentInsets, 0);
dest.writeBoolean(mReducedResolution);
dest.writeFloat(mScale);
@@ -2106,6 +2122,7 @@ public class ActivityManager {
+ " mSnapshot=" + mSnapshot + " (" + width + "x" + height + ")"
+ " mColorSpace=" + mColorSpace.toString()
+ " mOrientation=" + mOrientation
+ + " mRotation=" + mRotation
+ " mContentInsets=" + mContentInsets.toShortString()
+ " mReducedResolution=" + mReducedResolution + " mScale=" + mScale
+ " mIsRealSnapshot=" + mIsRealSnapshot + " mWindowingMode=" + mWindowingMode
@@ -2129,6 +2146,7 @@ public class ActivityManager {
private GraphicBuffer mSnapshot;
private ColorSpace mColorSpace;
private int mOrientation;
+ private int mRotation;
private Rect mContentInsets;
private boolean mReducedResolution;
private float mScaleFraction;
@@ -2163,6 +2181,11 @@ public class ActivityManager {
return this;
}
+ public Builder setRotation(int rotation) {
+ mRotation = rotation;
+ return this;
+ }
+
public Builder setContentInsets(Rect contentInsets) {
mContentInsets = contentInsets;
return this;
@@ -2218,6 +2241,7 @@ public class ActivityManager {
mSnapshot,
mColorSpace,
mOrientation,
+ mRotation,
mContentInsets,
mReducedResolution,
mScaleFraction,
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java
index 98b7e2484478..44a8d3c53db7 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java
@@ -16,6 +16,7 @@
package com.android.systemui.shared.recents.model;
+import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
import static android.content.res.Configuration.ORIENTATION_UNDEFINED;
import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_UNDEFINED;
@@ -31,6 +32,7 @@ public class ThumbnailData {
public final Bitmap thumbnail;
public int orientation;
+ public int rotation;
public Rect insets;
public boolean reducedResolution;
public boolean isRealSnapshot;
@@ -43,6 +45,7 @@ public class ThumbnailData {
public ThumbnailData() {
thumbnail = null;
orientation = ORIENTATION_UNDEFINED;
+ rotation = ROTATION_UNDEFINED;
insets = new Rect();
reducedResolution = false;
scale = 1f;
@@ -57,6 +60,7 @@ public class ThumbnailData {
thumbnail = Bitmap.wrapHardwareBuffer(snapshot.getSnapshot(), snapshot.getColorSpace());
insets = new Rect(snapshot.getContentInsets());
orientation = snapshot.getOrientation();
+ rotation = snapshot.getRotation();
reducedResolution = snapshot.isReducedResolution();
scale = snapshot.getScale();
isRealSnapshot = snapshot.isRealSnapshot();
diff --git a/proto/src/task_snapshot.proto b/proto/src/task_snapshot.proto
index 821db860dd96..789019ce8b75 100644
--- a/proto/src/task_snapshot.proto
+++ b/proto/src/task_snapshot.proto
@@ -34,4 +34,5 @@
string top_activity_component = 10;
float scale = 11;
int64 id = 12;
+ int32 rotation = 13;
}
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java
index 4cb5de44bef0..10d6823c850f 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotController.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java
@@ -343,6 +343,7 @@ class TaskSnapshotController {
builder.setPixelFormat(pixelFormat);
builder.setIsTranslucent(isTranslucent);
builder.setOrientation(activity.getTask().getConfiguration().orientation);
+ builder.setRotation(activity.getTask().getDisplayContent().getRotation());
builder.setWindowingMode(task.getWindowingMode());
builder.setSystemUiVisibility(getSystemUiVisibility(task));
return true;
@@ -492,7 +493,8 @@ class TaskSnapshotController {
return new TaskSnapshot(
System.currentTimeMillis() /* id */,
topChild.mActivityComponent, hwBitmap.createGraphicBufferHandle(),
- hwBitmap.getColorSpace(), topChild.getTask().getConfiguration().orientation,
+ hwBitmap.getColorSpace(), mainWindow.getConfiguration().orientation,
+ mainWindow.getWindowConfiguration().getRotation(),
getInsets(mainWindow), ActivityManager.isLowRamDeviceStatic() /* reduced */,
mFullSnapshotScale, false /* isRealSnapshot */, task.getWindowingMode(),
getSystemUiVisibility(task), false);
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotLoader.java b/services/core/java/com/android/server/wm/TaskSnapshotLoader.java
index 22c1ea59d176..6e9986ffd411 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotLoader.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotLoader.java
@@ -102,8 +102,8 @@ class TaskSnapshotLoader {
// For legacy snapshots, restore the scale based on the reduced resolution state
final float legacyScale = reducedResolution ? mPersister.getReducedScale() : 1f;
final float scale = Float.compare(proto.scale, 0f) != 0 ? proto.scale : legacyScale;
- return new TaskSnapshot(proto.id, topActivityComponent, buffer,
- hwBitmap.getColorSpace(), proto.orientation,
+ return new TaskSnapshot(proto.id, topActivityComponent, buffer, hwBitmap.getColorSpace(),
+ proto.orientation, proto.rotation,
new Rect(proto.insetLeft, proto.insetTop, proto.insetRight, proto.insetBottom),
reducedResolution, scale, proto.isRealSnapshot, proto.windowingMode,
proto.systemUiVisibility, proto.isTranslucent);
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotPersister.java b/services/core/java/com/android/server/wm/TaskSnapshotPersister.java
index 38a7000803bd..9585815a1914 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotPersister.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotPersister.java
@@ -338,6 +338,7 @@ class TaskSnapshotPersister {
boolean writeProto() {
final TaskSnapshotProto proto = new TaskSnapshotProto();
proto.orientation = mSnapshot.getOrientation();
+ proto.rotation = mSnapshot.getRotation();
proto.insetLeft = mSnapshot.getContentInsets().left;
proto.insetTop = mSnapshot.getContentInsets().top;
proto.insetRight = mSnapshot.getContentInsets().right;
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterLoaderTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterLoaderTest.java
index eb8eb98fd484..d73830468359 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterLoaderTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterLoaderTest.java
@@ -31,6 +31,7 @@ import android.graphics.Rect;
import android.os.SystemClock;
import android.platform.test.annotations.Presubmit;
import android.util.ArraySet;
+import android.view.Surface;
import android.view.View;
import androidx.test.filters.MediumTest;
@@ -47,7 +48,7 @@ import java.util.function.Predicate;
* Test class for {@link TaskSnapshotPersister} and {@link TaskSnapshotLoader}
*
* Build/Install/Run:
- * atest WmTests:TaskSnapshotPersisterLoaderTest
+ * atest TaskSnapshotPersisterLoaderTest
*/
@MediumTest
@Presubmit
@@ -316,4 +317,18 @@ public class TaskSnapshotPersisterLoaderTest extends TaskSnapshotPersisterTestBa
new File(FILES_DIR.getPath() + "/snapshots/2_reduced.jpg")};
assertTrueForFiles(existsFiles, File::exists, " must exist");
}
+
+ @Test
+ public void testRotationPersistAndLoadSnapshot() {
+ TaskSnapshot a = new TaskSnapshotBuilder()
+ .setRotation(Surface.ROTATION_270)
+ .build();
+ mPersister.persistSnapshot(1 , mTestUserId, createSnapshot());
+ mPersister.persistSnapshot(2 , mTestUserId, a);
+ mPersister.waitForQueueEmpty();
+ final TaskSnapshot snapshotA = mLoader.loadTask(1, mTestUserId, false /* reduced */);
+ final TaskSnapshot snapshotB = mLoader.loadTask(2, mTestUserId, false /* reduced */);
+ assertEquals(Surface.ROTATION_0, snapshotA.getRotation());
+ assertEquals(Surface.ROTATION_270, snapshotB.getRotation());
+ }
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java
index f7496229f66b..f86c9e63dc48 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java
@@ -32,6 +32,7 @@ import android.graphics.GraphicBuffer;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.UserManager;
+import android.view.Surface;
import org.junit.After;
import org.junit.Before;
@@ -93,6 +94,7 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase {
private boolean mIsTranslucent = false;
private int mWindowingMode = WINDOWING_MODE_FULLSCREEN;
private int mSystemUiVisibility = 0;
+ private int mRotation = Surface.ROTATION_0;
TaskSnapshotBuilder setScale(float scale) {
mScale = scale;
@@ -124,6 +126,11 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase {
return this;
}
+ TaskSnapshotBuilder setRotation(int rotation) {
+ mRotation = rotation;
+ return this;
+ }
+
TaskSnapshot build() {
final GraphicBuffer buffer = GraphicBuffer.create(100, 100, PixelFormat.RGBA_8888,
USAGE_HW_TEXTURE | USAGE_SW_READ_RARELY | USAGE_SW_READ_RARELY);
@@ -131,7 +138,8 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase {
c.drawColor(Color.RED);
buffer.unlockCanvasAndPost(c);
return new TaskSnapshot(MOCK_SNAPSHOT_ID, new ComponentName("", ""), buffer,
- ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT, TEST_INSETS,
+ ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT,
+ mRotation, TEST_INSETS,
mReducedResolution, mScale, mIsRealSnapshot,
mWindowingMode, mSystemUiVisibility, mIsTranslucent);
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java
index ed87f3a0c604..bb0e5aec8e2e 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java
@@ -40,6 +40,7 @@ import android.graphics.GraphicBuffer;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
+import android.view.Surface;
import android.view.SurfaceControl;
import androidx.test.filters.SmallTest;
@@ -69,7 +70,8 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
final TaskSnapshot snapshot = new TaskSnapshot(
System.currentTimeMillis(),
new ComponentName("", ""), buffer,
- ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT, contentInsets, false,
+ ColorSpace.get(ColorSpace.Named.SRGB), ORIENTATION_PORTRAIT,
+ Surface.ROTATION_0, contentInsets, false,
1.0f, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN,
0 /* systemUiVisibility */, false /* isTranslucent */);
mSurface = new TaskSnapshotSurface(mWm, new Window(), new SurfaceControl(), snapshot, "Test",