Loading core/java/android/app/ActivityManager.java +13 −7 Original line number Diff line number Diff line Loading @@ -1838,17 +1838,17 @@ public class ActivityManager { private final float mScale; private final int mSystemUiVisibility; private final boolean mIsTranslucent; // TODO(b/116112787) TaskSnapshot must also book keep the color space from hardware bitmap // when created. private final ColorSpace mColorSpace = ColorSpace.get(ColorSpace.Named.SRGB); // Must be one of the named color spaces, otherwise, always use SRGB color space. private final ColorSpace mColorSpace; public TaskSnapshot(@NonNull ComponentName topActivityComponent, GraphicBuffer snapshot, int orientation, Rect contentInsets, boolean reducedResolution, float scale, boolean isRealSnapshot, int windowingMode, int systemUiVisibility, boolean isTranslucent) { @NonNull ColorSpace colorSpace, int orientation, Rect contentInsets, boolean reducedResolution, float scale, boolean isRealSnapshot, int windowingMode, int systemUiVisibility, boolean isTranslucent) { mTopActivityComponent = topActivityComponent; mSnapshot = snapshot; mColorSpace = colorSpace.getId() < 0 ? ColorSpace.get(ColorSpace.Named.SRGB) : colorSpace; mOrientation = orientation; mContentInsets = new Rect(contentInsets); mReducedResolution = reducedResolution; Loading @@ -1862,6 +1862,10 @@ public class ActivityManager { private TaskSnapshot(Parcel source) { mTopActivityComponent = ComponentName.readFromParcel(source); mSnapshot = source.readParcelable(null /* classLoader */); int colorSpaceId = source.readInt(); mColorSpace = colorSpaceId >= 0 ? ColorSpace.get(ColorSpace.Named.values()[colorSpaceId]) : ColorSpace.get(ColorSpace.Named.SRGB); mOrientation = source.readInt(); mContentInsets = source.readParcelable(null /* classLoader */); mReducedResolution = source.readBoolean(); Loading Loading @@ -1968,6 +1972,7 @@ public class ActivityManager { public void writeToParcel(Parcel dest, int flags) { ComponentName.writeToParcel(mTopActivityComponent, dest); dest.writeParcelable(mSnapshot, 0); dest.writeInt(mColorSpace.getId()); dest.writeInt(mOrientation); dest.writeParcelable(mContentInsets, 0); dest.writeBoolean(mReducedResolution); Loading @@ -1985,6 +1990,7 @@ public class ActivityManager { return "TaskSnapshot{" + " mTopActivityComponent=" + mTopActivityComponent.flattenToShortString() + " mSnapshot=" + mSnapshot + " (" + width + "x" + height + ")" + " mColorSpace=" + mColorSpace.toString() + " mOrientation=" + mOrientation + " mContentInsets=" + mContentInsets.toShortString() + " mReducedResolution=" + mReducedResolution + " mScale=" + mScale Loading core/java/android/view/SurfaceControl.java +6 −4 Original line number Diff line number Diff line Loading @@ -90,8 +90,8 @@ public final class SurfaceControl implements Parcelable { private static native ScreenshotGraphicBuffer nativeScreenshot(IBinder displayToken, Rect sourceCrop, int width, int height, boolean useIdentityTransform, int rotation, boolean captureSecureLayers); private static native ScreenshotGraphicBuffer nativeCaptureLayers(IBinder layerHandleToken, Rect sourceCrop, float frameScale, IBinder[] excludeLayers); private static native ScreenshotGraphicBuffer nativeCaptureLayers(IBinder displayToken, IBinder layerHandleToken, Rect sourceCrop, float frameScale, IBinder[] excludeLayers); private static native long nativeCreateTransaction(); private static native long nativeGetNativeTransactionFinalizer(); Loading Loading @@ -1998,7 +1998,8 @@ public final class SurfaceControl implements Parcelable { */ public static ScreenshotGraphicBuffer captureLayers(IBinder layerHandleToken, Rect sourceCrop, float frameScale) { return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale, null); final IBinder displayToken = SurfaceControl.getInternalDisplayToken(); return nativeCaptureLayers(displayToken, layerHandleToken, sourceCrop, frameScale, null); } /** Loading @@ -2007,7 +2008,8 @@ public final class SurfaceControl implements Parcelable { */ public static ScreenshotGraphicBuffer captureLayersExcluding(IBinder layerHandleToken, Rect sourceCrop, float frameScale, IBinder[] exclude) { return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale, exclude); final IBinder displayToken = SurfaceControl.getInternalDisplayToken(); return nativeCaptureLayers(displayToken, layerHandleToken, sourceCrop, frameScale, exclude); } /** Loading core/jni/android_view_SurfaceControl.cpp +11 −4 Original line number Diff line number Diff line Loading @@ -271,8 +271,9 @@ static jobject nativeScreenshot(JNIEnv* env, jclass clazz, capturedSecureLayers); } static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandleToken, jobject sourceCropObj, jfloat frameScale, jobjectArray excludeArray) { static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject displayTokenObj, jobject layerHandleToken, jobject sourceCropObj, jfloat frameScale, jobjectArray excludeArray) { sp<IBinder> layerHandle = ibinderForJavaObject(env, layerHandleToken); if (layerHandle == NULL) { Loading Loading @@ -301,7 +302,12 @@ static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandl } sp<GraphicBuffer> buffer; const ui::Dataspace dataspace = ui::Dataspace::V0_SRGB; ui::Dataspace dataspace = ui::Dataspace::V0_SRGB; sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj); if (displayToken != nullptr) { const ui::ColorMode colorMode = SurfaceComposerClient::getActiveColorMode(displayToken); dataspace = pickDataspaceFromColorMode(colorMode); } status_t res = ScreenshotClient::captureChildLayers(layerHandle, dataspace, ui::PixelFormat::RGBA_8888, sourceCrop, excludeHandles, frameScale, &buffer); Loading Loading @@ -1373,7 +1379,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = { "Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;", (void*)nativeScreenshot }, {"nativeCaptureLayers", "(Landroid/os/IBinder;Landroid/graphics/Rect;F[Landroid/os/IBinder;)" "(Landroid/os/IBinder;Landroid/os/IBinder;Landroid/graphics/Rect;" "F[Landroid/os/IBinder;)" "Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;", (void*)nativeCaptureLayers }, {"nativeSetInputWindowInfo", "(JJLandroid/view/InputWindowHandle;)V", Loading services/core/java/com/android/server/wm/TaskSnapshotController.java +7 −7 Original line number Diff line number Diff line Loading @@ -292,9 +292,9 @@ class TaskSnapshotController { } final boolean isWindowTranslucent = mainWindow.getAttrs().format != PixelFormat.OPAQUE; return new TaskSnapshot(appWindowToken.mActivityComponent, buffer, appWindowToken.getConfiguration().orientation, getInsets(mainWindow), isLowRamDevice /* reduced */, scaleFraction /* scale */, true /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task), screenshotBuffer.getColorSpace(), appWindowToken.getConfiguration().orientation, getInsets(mainWindow), isLowRamDevice /* reduced */, scaleFraction /* scale */, true /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task), !appWindowToken.fillsParent() || isWindowTranslucent); } Loading Loading @@ -383,10 +383,10 @@ class TaskSnapshotController { // Note, the app theme snapshot is never translucent because we enforce a non-translucent // color above return new TaskSnapshot(topChild.mActivityComponent, hwBitmap.createGraphicBufferHandle(), topChild.getConfiguration().orientation, mainWindow.getStableInsets(), ActivityManager.isLowRamDeviceStatic() /* reduced */, 1.0f /* scale */, false /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task), false); hwBitmap.getColorSpace(), topChild.getConfiguration().orientation, mainWindow.getStableInsets(), ActivityManager.isLowRamDeviceStatic() /* reduced */, 1.0f /* scale */, false /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task), false); } /** Loading services/core/java/com/android/server/wm/TaskSnapshotLoader.java +2 −1 Original line number Diff line number Diff line Loading @@ -89,7 +89,8 @@ class TaskSnapshotLoader { } ComponentName topActivityComponent = ComponentName.unflattenFromString( proto.topActivityComponent); return new TaskSnapshot(topActivityComponent, buffer, proto.orientation, return new TaskSnapshot(topActivityComponent, buffer, bitmap.getColorSpace(), proto.orientation, new Rect(proto.insetLeft, proto.insetTop, proto.insetRight, proto.insetBottom), reducedResolution, reducedResolution ? mPersister.getReducedScale() : 1f, proto.isRealSnapshot, proto.windowingMode, proto.systemUiVisibility, Loading Loading
core/java/android/app/ActivityManager.java +13 −7 Original line number Diff line number Diff line Loading @@ -1838,17 +1838,17 @@ public class ActivityManager { private final float mScale; private final int mSystemUiVisibility; private final boolean mIsTranslucent; // TODO(b/116112787) TaskSnapshot must also book keep the color space from hardware bitmap // when created. private final ColorSpace mColorSpace = ColorSpace.get(ColorSpace.Named.SRGB); // Must be one of the named color spaces, otherwise, always use SRGB color space. private final ColorSpace mColorSpace; public TaskSnapshot(@NonNull ComponentName topActivityComponent, GraphicBuffer snapshot, int orientation, Rect contentInsets, boolean reducedResolution, float scale, boolean isRealSnapshot, int windowingMode, int systemUiVisibility, boolean isTranslucent) { @NonNull ColorSpace colorSpace, int orientation, Rect contentInsets, boolean reducedResolution, float scale, boolean isRealSnapshot, int windowingMode, int systemUiVisibility, boolean isTranslucent) { mTopActivityComponent = topActivityComponent; mSnapshot = snapshot; mColorSpace = colorSpace.getId() < 0 ? ColorSpace.get(ColorSpace.Named.SRGB) : colorSpace; mOrientation = orientation; mContentInsets = new Rect(contentInsets); mReducedResolution = reducedResolution; Loading @@ -1862,6 +1862,10 @@ public class ActivityManager { private TaskSnapshot(Parcel source) { mTopActivityComponent = ComponentName.readFromParcel(source); mSnapshot = source.readParcelable(null /* classLoader */); int colorSpaceId = source.readInt(); mColorSpace = colorSpaceId >= 0 ? ColorSpace.get(ColorSpace.Named.values()[colorSpaceId]) : ColorSpace.get(ColorSpace.Named.SRGB); mOrientation = source.readInt(); mContentInsets = source.readParcelable(null /* classLoader */); mReducedResolution = source.readBoolean(); Loading Loading @@ -1968,6 +1972,7 @@ public class ActivityManager { public void writeToParcel(Parcel dest, int flags) { ComponentName.writeToParcel(mTopActivityComponent, dest); dest.writeParcelable(mSnapshot, 0); dest.writeInt(mColorSpace.getId()); dest.writeInt(mOrientation); dest.writeParcelable(mContentInsets, 0); dest.writeBoolean(mReducedResolution); Loading @@ -1985,6 +1990,7 @@ public class ActivityManager { return "TaskSnapshot{" + " mTopActivityComponent=" + mTopActivityComponent.flattenToShortString() + " mSnapshot=" + mSnapshot + " (" + width + "x" + height + ")" + " mColorSpace=" + mColorSpace.toString() + " mOrientation=" + mOrientation + " mContentInsets=" + mContentInsets.toShortString() + " mReducedResolution=" + mReducedResolution + " mScale=" + mScale Loading
core/java/android/view/SurfaceControl.java +6 −4 Original line number Diff line number Diff line Loading @@ -90,8 +90,8 @@ public final class SurfaceControl implements Parcelable { private static native ScreenshotGraphicBuffer nativeScreenshot(IBinder displayToken, Rect sourceCrop, int width, int height, boolean useIdentityTransform, int rotation, boolean captureSecureLayers); private static native ScreenshotGraphicBuffer nativeCaptureLayers(IBinder layerHandleToken, Rect sourceCrop, float frameScale, IBinder[] excludeLayers); private static native ScreenshotGraphicBuffer nativeCaptureLayers(IBinder displayToken, IBinder layerHandleToken, Rect sourceCrop, float frameScale, IBinder[] excludeLayers); private static native long nativeCreateTransaction(); private static native long nativeGetNativeTransactionFinalizer(); Loading Loading @@ -1998,7 +1998,8 @@ public final class SurfaceControl implements Parcelable { */ public static ScreenshotGraphicBuffer captureLayers(IBinder layerHandleToken, Rect sourceCrop, float frameScale) { return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale, null); final IBinder displayToken = SurfaceControl.getInternalDisplayToken(); return nativeCaptureLayers(displayToken, layerHandleToken, sourceCrop, frameScale, null); } /** Loading @@ -2007,7 +2008,8 @@ public final class SurfaceControl implements Parcelable { */ public static ScreenshotGraphicBuffer captureLayersExcluding(IBinder layerHandleToken, Rect sourceCrop, float frameScale, IBinder[] exclude) { return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale, exclude); final IBinder displayToken = SurfaceControl.getInternalDisplayToken(); return nativeCaptureLayers(displayToken, layerHandleToken, sourceCrop, frameScale, exclude); } /** Loading
core/jni/android_view_SurfaceControl.cpp +11 −4 Original line number Diff line number Diff line Loading @@ -271,8 +271,9 @@ static jobject nativeScreenshot(JNIEnv* env, jclass clazz, capturedSecureLayers); } static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandleToken, jobject sourceCropObj, jfloat frameScale, jobjectArray excludeArray) { static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject displayTokenObj, jobject layerHandleToken, jobject sourceCropObj, jfloat frameScale, jobjectArray excludeArray) { sp<IBinder> layerHandle = ibinderForJavaObject(env, layerHandleToken); if (layerHandle == NULL) { Loading Loading @@ -301,7 +302,12 @@ static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandl } sp<GraphicBuffer> buffer; const ui::Dataspace dataspace = ui::Dataspace::V0_SRGB; ui::Dataspace dataspace = ui::Dataspace::V0_SRGB; sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj); if (displayToken != nullptr) { const ui::ColorMode colorMode = SurfaceComposerClient::getActiveColorMode(displayToken); dataspace = pickDataspaceFromColorMode(colorMode); } status_t res = ScreenshotClient::captureChildLayers(layerHandle, dataspace, ui::PixelFormat::RGBA_8888, sourceCrop, excludeHandles, frameScale, &buffer); Loading Loading @@ -1373,7 +1379,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = { "Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;", (void*)nativeScreenshot }, {"nativeCaptureLayers", "(Landroid/os/IBinder;Landroid/graphics/Rect;F[Landroid/os/IBinder;)" "(Landroid/os/IBinder;Landroid/os/IBinder;Landroid/graphics/Rect;" "F[Landroid/os/IBinder;)" "Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;", (void*)nativeCaptureLayers }, {"nativeSetInputWindowInfo", "(JJLandroid/view/InputWindowHandle;)V", Loading
services/core/java/com/android/server/wm/TaskSnapshotController.java +7 −7 Original line number Diff line number Diff line Loading @@ -292,9 +292,9 @@ class TaskSnapshotController { } final boolean isWindowTranslucent = mainWindow.getAttrs().format != PixelFormat.OPAQUE; return new TaskSnapshot(appWindowToken.mActivityComponent, buffer, appWindowToken.getConfiguration().orientation, getInsets(mainWindow), isLowRamDevice /* reduced */, scaleFraction /* scale */, true /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task), screenshotBuffer.getColorSpace(), appWindowToken.getConfiguration().orientation, getInsets(mainWindow), isLowRamDevice /* reduced */, scaleFraction /* scale */, true /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task), !appWindowToken.fillsParent() || isWindowTranslucent); } Loading Loading @@ -383,10 +383,10 @@ class TaskSnapshotController { // Note, the app theme snapshot is never translucent because we enforce a non-translucent // color above return new TaskSnapshot(topChild.mActivityComponent, hwBitmap.createGraphicBufferHandle(), topChild.getConfiguration().orientation, mainWindow.getStableInsets(), ActivityManager.isLowRamDeviceStatic() /* reduced */, 1.0f /* scale */, false /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task), false); hwBitmap.getColorSpace(), topChild.getConfiguration().orientation, mainWindow.getStableInsets(), ActivityManager.isLowRamDeviceStatic() /* reduced */, 1.0f /* scale */, false /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task), false); } /** Loading
services/core/java/com/android/server/wm/TaskSnapshotLoader.java +2 −1 Original line number Diff line number Diff line Loading @@ -89,7 +89,8 @@ class TaskSnapshotLoader { } ComponentName topActivityComponent = ComponentName.unflattenFromString( proto.topActivityComponent); return new TaskSnapshot(topActivityComponent, buffer, proto.orientation, return new TaskSnapshot(topActivityComponent, buffer, bitmap.getColorSpace(), proto.orientation, new Rect(proto.insetLeft, proto.insetTop, proto.insetRight, proto.insetBottom), reducedResolution, reducedResolution ? mPersister.getReducedScale() : 1f, proto.isRealSnapshot, proto.windowingMode, proto.systemUiVisibility, Loading