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) {
mReducedResolution = source.readBoolean();
mScale = source.readFloat();
mIsRealSnapshot = source.readBoolean();
+ mWindowingMode = source.readInt();
}
/**
}
/**
+ * @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.
*/
public float getScale() {
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>() {
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;
public Rect insets;
public boolean reducedResolution;
public boolean isRealSnapshot;
+ public int windowingMode;
public float scale;
public ThumbnailData() {
reducedResolution = false;
scale = 1f;
isRealSnapshot = true;
+ windowingMode = WINDOWING_MODE_UNDEFINED;
}
public ThumbnailData(TaskSnapshot snapshot) {
reducedResolution = snapshot.isReducedResolution();
scale = snapshot.getScale();
isRealSnapshot = snapshot.isRealSnapshot();
+ windowingMode = snapshot.getWindowingMode();
}
}
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() {
int32 inset_right = 4;
int32 inset_bottom = 5;
bool is_real_snapshot = 6;
+ int32 windowing_mode = 7;
}
\ No newline at end of file
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() {
return new TaskSnapshot(hwBitmap.createGraphicBufferHandle(),
topChild.getConfiguration().orientation, mainWindow.mStableInsets,
ActivityManager.isLowRamDeviceStatic() /* reduced */, 1.0f /* scale */,
- false /* isRealSnapshot */);
+ false /* isRealSnapshot */, task.getWindowingMode());
}
/**
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;
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;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayDeque;
-import java.util.ArrayList;
/**
* Persists {@link TaskSnapshot}s to disk.
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);
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;
@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);
}
@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());
mPersister.persistSnapshot(2, mTestUserId, createSnapshot());
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;
}
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);
}
}
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;
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);