Add windowing mode to task snapshot.
Bug: 78155683 Test: atest FrameworksServicesTests:TaskSnapshotPersisterLoaderTest Change-Id: I4e562d818416a30d6759baef37c74b6d9c514a00
This commit is contained in:
@@ -2102,18 +2102,24 @@ public class ActivityManager {
|
||||
private final GraphicBuffer mSnapshot;
|
||||
private final int mOrientation;
|
||||
private final Rect mContentInsets;
|
||||
// Whether this snapshot is a down-sampled version of the full resolution, used mainly for
|
||||
// low-ram devices
|
||||
private final boolean mReducedResolution;
|
||||
// Whether or not the snapshot is a real snapshot or an app-theme generated snapshot due to
|
||||
// the task having a secure window or having previews disabled
|
||||
private final boolean mIsRealSnapshot;
|
||||
private final int mWindowingMode;
|
||||
private final float mScale;
|
||||
|
||||
public TaskSnapshot(GraphicBuffer snapshot, int orientation, Rect contentInsets,
|
||||
boolean reducedResolution, float scale, boolean isRealSnapshot) {
|
||||
boolean reducedResolution, float scale, boolean isRealSnapshot, int windowingMode) {
|
||||
mSnapshot = snapshot;
|
||||
mOrientation = orientation;
|
||||
mContentInsets = new Rect(contentInsets);
|
||||
mReducedResolution = reducedResolution;
|
||||
mScale = scale;
|
||||
mIsRealSnapshot = isRealSnapshot;
|
||||
mWindowingMode = windowingMode;
|
||||
}
|
||||
|
||||
private TaskSnapshot(Parcel source) {
|
||||
@@ -2123,6 +2129,7 @@ public class ActivityManager {
|
||||
mReducedResolution = source.readBoolean();
|
||||
mScale = source.readFloat();
|
||||
mIsRealSnapshot = source.readBoolean();
|
||||
mWindowingMode = source.readInt();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2162,6 +2169,13 @@ public class ActivityManager {
|
||||
return mIsRealSnapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The windowing mode of the task when this snapshot was taken.
|
||||
*/
|
||||
public int getWindowingMode() {
|
||||
return mWindowingMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The scale this snapshot was taken in.
|
||||
*/
|
||||
@@ -2182,14 +2196,18 @@ public class ActivityManager {
|
||||
dest.writeBoolean(mReducedResolution);
|
||||
dest.writeFloat(mScale);
|
||||
dest.writeBoolean(mIsRealSnapshot);
|
||||
dest.writeInt(mWindowingMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TaskSnapshot{mSnapshot=" + mSnapshot + " mOrientation=" + mOrientation
|
||||
final int width = mSnapshot != null ? mSnapshot.getWidth() : 0;
|
||||
final int height = mSnapshot != null ? mSnapshot.getHeight() : 0;
|
||||
return "TaskSnapshot{mSnapshot=" + mSnapshot + " (" + width + "x" + height + ")"
|
||||
+ " mOrientation=" + mOrientation
|
||||
+ " mContentInsets=" + mContentInsets.toShortString()
|
||||
+ " mReducedResolution=" + mReducedResolution + " mScale=" + mScale
|
||||
+ " mIsRealSnapshot=" + mIsRealSnapshot;
|
||||
+ " mIsRealSnapshot=" + mIsRealSnapshot + " mWindowingMode=" + mWindowingMode;
|
||||
}
|
||||
|
||||
public static final Creator<TaskSnapshot> CREATOR = new Creator<TaskSnapshot>() {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.systemui.shared.recents.model;
|
||||
|
||||
import static android.content.res.Configuration.ORIENTATION_UNDEFINED;
|
||||
import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_UNDEFINED;
|
||||
|
||||
import android.app.ActivityManager.TaskSnapshot;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -32,6 +33,7 @@ public class ThumbnailData {
|
||||
public Rect insets;
|
||||
public boolean reducedResolution;
|
||||
public boolean isRealSnapshot;
|
||||
public int windowingMode;
|
||||
public float scale;
|
||||
|
||||
public ThumbnailData() {
|
||||
@@ -41,6 +43,7 @@ public class ThumbnailData {
|
||||
reducedResolution = false;
|
||||
scale = 1f;
|
||||
isRealSnapshot = true;
|
||||
windowingMode = WINDOWING_MODE_UNDEFINED;
|
||||
}
|
||||
|
||||
public ThumbnailData(TaskSnapshot snapshot) {
|
||||
@@ -50,5 +53,6 @@ public class ThumbnailData {
|
||||
reducedResolution = snapshot.isReducedResolution();
|
||||
scale = snapshot.getScale();
|
||||
isRealSnapshot = snapshot.isRealSnapshot();
|
||||
windowingMode = snapshot.getWindowingMode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,16 @@ public class WindowManagerWrapper {
|
||||
|
||||
public static final int ACTIVITY_TYPE_STANDARD = WindowConfiguration.ACTIVITY_TYPE_STANDARD;
|
||||
|
||||
public static final int WINDOWING_MODE_UNDEFINED = WindowConfiguration.WINDOWING_MODE_UNDEFINED;
|
||||
public static final int WINDOWING_MODE_FULLSCREEN =
|
||||
WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||
public static final int WINDOWING_MODE_PINNED = WindowConfiguration.WINDOWING_MODE_PINNED;
|
||||
public static final int WINDOWING_MODE_SPLIT_SCREEN_PRIMARY =
|
||||
WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
|
||||
public static final int WINDOWING_MODE_SPLIT_SCREEN_SECONDARY =
|
||||
WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
|
||||
public static final int WINDOWING_MODE_FREEFORM = WindowConfiguration.WINDOWING_MODE_FREEFORM;
|
||||
|
||||
private static final WindowManagerWrapper sInstance = new WindowManagerWrapper();
|
||||
|
||||
public static WindowManagerWrapper getInstance() {
|
||||
|
||||
@@ -28,4 +28,5 @@
|
||||
int32 inset_right = 4;
|
||||
int32 inset_bottom = 5;
|
||||
bool is_real_snapshot = 6;
|
||||
int32 windowing_mode = 7;
|
||||
}
|
||||
@@ -273,9 +273,8 @@ class TaskSnapshotController {
|
||||
return null;
|
||||
}
|
||||
return new TaskSnapshot(buffer, top.getConfiguration().orientation,
|
||||
getInsets(mainWindow),
|
||||
isLowRamDevice /* reduced */, scaleFraction /* scale */,
|
||||
true /* isRealSnapshot */);
|
||||
getInsets(mainWindow), isLowRamDevice /* reduced */, scaleFraction /* scale */,
|
||||
true /* isRealSnapshot */, task.getWindowingMode());
|
||||
}
|
||||
|
||||
private boolean shouldDisableSnapshots() {
|
||||
@@ -365,7 +364,7 @@ class TaskSnapshotController {
|
||||
return new TaskSnapshot(hwBitmap.createGraphicBufferHandle(),
|
||||
topChild.getConfiguration().orientation, mainWindow.mStableInsets,
|
||||
ActivityManager.isLowRamDeviceStatic() /* reduced */, 1.0f /* scale */,
|
||||
false /* isRealSnapshot */);
|
||||
false /* isRealSnapshot */, task.getWindowingMode());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,7 +90,7 @@ class TaskSnapshotLoader {
|
||||
return new TaskSnapshot(buffer, proto.orientation,
|
||||
new Rect(proto.insetLeft, proto.insetTop, proto.insetRight, proto.insetBottom),
|
||||
reducedResolution, reducedResolution ? REDUCED_SCALE : 1f,
|
||||
proto.isRealSnapshot);
|
||||
proto.isRealSnapshot, proto.windowingMode);
|
||||
} catch (IOException e) {
|
||||
Slog.w(TAG, "Unable to load task snapshot data for taskId=" + taskId);
|
||||
return null;
|
||||
|
||||
@@ -24,9 +24,7 @@ import android.annotation.TestApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.TaskSnapshot;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.CompressFormat;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.GraphicBuffer;
|
||||
import android.os.Process;
|
||||
import android.os.SystemClock;
|
||||
import android.util.ArraySet;
|
||||
@@ -41,7 +39,6 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Persists {@link TaskSnapshot}s to disk.
|
||||
@@ -319,6 +316,7 @@ class TaskSnapshotPersister {
|
||||
proto.insetRight = mSnapshot.getContentInsets().right;
|
||||
proto.insetBottom = mSnapshot.getContentInsets().bottom;
|
||||
proto.isRealSnapshot = mSnapshot.isRealSnapshot();
|
||||
proto.windowingMode = mSnapshot.getWindowingMode();
|
||||
final byte[] bytes = TaskSnapshotProto.toByteArray(proto);
|
||||
final File file = getProtoFile(mTaskId, mUserId);
|
||||
final AtomicFile atomicFile = new AtomicFile(file);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -164,8 +166,10 @@ public class TaskSnapshotPersisterLoaderTest extends TaskSnapshotPersisterTestBa
|
||||
|
||||
@Test
|
||||
public void testIsRealSnapshotPersistAndLoadSnapshot() {
|
||||
TaskSnapshot a = createSnapshot(1f /* scale */, true /* isRealSnapshot */);
|
||||
TaskSnapshot b = createSnapshot(1f /* scale */, false /* isRealSnapshot */);
|
||||
TaskSnapshot a = createSnapshot(1f /* scale */, true /* isRealSnapshot */,
|
||||
WINDOWING_MODE_FULLSCREEN);
|
||||
TaskSnapshot b = createSnapshot(1f /* scale */, false /* isRealSnapshot */,
|
||||
WINDOWING_MODE_FULLSCREEN);
|
||||
assertTrue(a.isRealSnapshot());
|
||||
assertFalse(b.isRealSnapshot());
|
||||
mPersister.persistSnapshot(1, mTestUserId, a);
|
||||
@@ -179,6 +183,25 @@ public class TaskSnapshotPersisterLoaderTest extends TaskSnapshotPersisterTestBa
|
||||
assertFalse(snapshotB.isRealSnapshot());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWindowingModePersistAndLoadSnapshot() {
|
||||
TaskSnapshot a = createSnapshot(1f /* scale */, true /* isRealSnapshot */,
|
||||
WINDOWING_MODE_FULLSCREEN);
|
||||
TaskSnapshot b = createSnapshot(1f /* scale */, true /* isRealSnapshot */,
|
||||
WINDOWING_MODE_PINNED);
|
||||
assertTrue(a.getWindowingMode() == WINDOWING_MODE_FULLSCREEN);
|
||||
assertTrue(b.getWindowingMode() == WINDOWING_MODE_PINNED);
|
||||
mPersister.persistSnapshot(1, mTestUserId, a);
|
||||
mPersister.persistSnapshot(2, mTestUserId, b);
|
||||
mPersister.waitForQueueEmpty();
|
||||
final TaskSnapshot snapshotA = mLoader.loadTask(1, mTestUserId, false /* reduced */);
|
||||
final TaskSnapshot snapshotB = mLoader.loadTask(2, mTestUserId, false /* reduced */);
|
||||
assertNotNull(snapshotA);
|
||||
assertNotNull(snapshotB);
|
||||
assertTrue(snapshotA.getWindowingMode() == WINDOWING_MODE_FULLSCREEN);
|
||||
assertTrue(snapshotB.getWindowingMode() == WINDOWING_MODE_PINNED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveObsoleteFiles() {
|
||||
mPersister.persistSnapshot(1, mTestUserId, createSnapshot());
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
|
||||
import static android.graphics.GraphicBuffer.USAGE_HW_TEXTURE;
|
||||
import static android.graphics.GraphicBuffer.USAGE_SW_READ_RARELY;
|
||||
@@ -84,16 +85,16 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase {
|
||||
}
|
||||
|
||||
TaskSnapshot createSnapshot(float scale) {
|
||||
return createSnapshot(scale, true /* isRealSnapshot */);
|
||||
return createSnapshot(scale, true /* isRealSnapshot */, WINDOWING_MODE_FULLSCREEN);
|
||||
}
|
||||
|
||||
TaskSnapshot createSnapshot(float scale, boolean isRealSnapshot) {
|
||||
TaskSnapshot createSnapshot(float scale, boolean isRealSnapshot, int windowingMode) {
|
||||
final GraphicBuffer buffer = GraphicBuffer.create(100, 100, PixelFormat.RGBA_8888,
|
||||
USAGE_HW_TEXTURE | USAGE_SW_READ_RARELY | USAGE_SW_READ_RARELY);
|
||||
Canvas c = buffer.lockCanvas();
|
||||
c.drawColor(Color.RED);
|
||||
buffer.unlockCanvasAndPost(c);
|
||||
return new TaskSnapshot(buffer, ORIENTATION_PORTRAIT, TEST_INSETS,
|
||||
scale < 1f /* reducedResolution */, scale, isRealSnapshot);
|
||||
scale < 1f /* reducedResolution */, scale, isRealSnapshot, windowingMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
||||
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -60,7 +61,8 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
|
||||
final GraphicBuffer buffer = GraphicBuffer.create(width, height, PixelFormat.RGBA_8888,
|
||||
GraphicBuffer.USAGE_SW_READ_NEVER | GraphicBuffer.USAGE_SW_WRITE_NEVER);
|
||||
final TaskSnapshot snapshot = new TaskSnapshot(buffer,
|
||||
ORIENTATION_PORTRAIT, contentInsets, false, 1.0f, true /* isRealSnapshot */);
|
||||
ORIENTATION_PORTRAIT, contentInsets, false, 1.0f, true /* isRealSnapshot */,
|
||||
WINDOWING_MODE_FULLSCREEN);
|
||||
mSurface = new TaskSnapshotSurface(sWm, new Window(), new Surface(), snapshot, "Test",
|
||||
Color.WHITE, Color.RED, Color.BLUE, sysuiVis, windowFlags, 0, taskBounds,
|
||||
ORIENTATION_PORTRAIT);
|
||||
|
||||
Reference in New Issue
Block a user