Set pixel format of snapshot builder
Otherwise the format is unknown and captureLayers may return empty GraphicBuffer. Bug: 140811348 Test: atest TaskSnapshotControllerTest#testPrepareTaskSnapshot Change-Id: I236c22046e824e9ac820c05372ec1b9668fba448
This commit is contained in:
@@ -281,7 +281,8 @@ class TaskSnapshotController {
|
||||
*
|
||||
* @return true if the state of the task is ok to proceed
|
||||
*/
|
||||
private boolean prepareTaskSnapshot(Task task, float scaleFraction, int pixelFormat,
|
||||
@VisibleForTesting
|
||||
boolean prepareTaskSnapshot(Task task, float scaleFraction, int pixelFormat,
|
||||
TaskSnapshot.Builder builder) {
|
||||
if (!mService.mPolicy.isScreenOn()) {
|
||||
if (DEBUG_SCREENSHOT) {
|
||||
@@ -339,6 +340,7 @@ class TaskSnapshotController {
|
||||
&& (!activity.fillsParent() || isWindowTranslucent);
|
||||
|
||||
builder.setTopActivityComponent(activity.mActivityComponent);
|
||||
builder.setPixelFormat(pixelFormat);
|
||||
builder.setIsTranslucent(isTranslucent);
|
||||
builder.setOrientation(activity.getTask().getConfiguration().orientation);
|
||||
builder.setWindowingMode(task.getWindowingMode());
|
||||
|
||||
@@ -19,10 +19,13 @@ package com.android.server.wm;
|
||||
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
|
||||
import static com.android.server.wm.TaskSnapshotController.SNAPSHOT_MODE_APP_THEME;
|
||||
import static com.android.server.wm.TaskSnapshotController.SNAPSHOT_MODE_REAL;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -175,4 +178,22 @@ public class TaskSnapshotControllerTest extends WindowTestsBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrepareTaskSnapshot() {
|
||||
mAppWindow.mWinAnimator.mLastAlpha = 1f;
|
||||
spyOn(mAppWindow.mWinAnimator);
|
||||
doReturn(true).when(mAppWindow.mWinAnimator).getShown();
|
||||
doReturn(true).when(mAppWindow.mActivityRecord).isSurfaceShowing();
|
||||
|
||||
final ActivityManager.TaskSnapshot.Builder builder =
|
||||
new ActivityManager.TaskSnapshot.Builder();
|
||||
final float scaleFraction = 0.8f;
|
||||
mWm.mTaskSnapshotController.prepareTaskSnapshot(mAppWindow.mActivityRecord.getTask(),
|
||||
scaleFraction, PixelFormat.UNKNOWN, builder);
|
||||
|
||||
assertEquals(scaleFraction, builder.getScaleFraction(), 0 /* delta */);
|
||||
// The pixel format should be selected automatically.
|
||||
assertNotEquals(PixelFormat.UNKNOWN, builder.getPixelFormat());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user