summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Robert Carr <racarr@google.com> 2019-04-02 11:51:11 -0700
committer Robert Carr <racarr@google.com> 2019-04-04 09:23:47 -0700
commitffcdc51319544ea61a0ca182a1c433e5c8c064fb (patch)
tree903dad65734c217ee4cdf05c70b0d035e151b52a
parentdd07ae579c291a2b6ffe09bd576fd908eb9e5ddd (diff)
SurfaceFlinger: Add exclusion list for captureLayers.
Among other use cases, WM needs to be able to omit the IME from Task Snapshots, even while it is on-screen. Bug: 126614127 Test: Transaction_test.cpp#CaptureLayerExclude Change-Id: I055d99106c9ce2ed90d64eca06961d88cbd5e2d4
-rw-r--r--core/java/android/view/SurfaceControl.java13
-rw-r--r--core/jni/android_view_SurfaceControl.cpp22
2 files changed, 30 insertions, 5 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index e3b0b7a58438..be7e1bb73610 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -92,7 +92,7 @@ public final class SurfaceControl implements Parcelable {
Rect sourceCrop, int width, int height, boolean useIdentityTransform, int rotation,
boolean captureSecureLayers);
private static native ScreenshotGraphicBuffer nativeCaptureLayers(IBinder layerHandleToken,
- Rect sourceCrop, float frameScale);
+ Rect sourceCrop, float frameScale, IBinder[] excludeLayers);
private static native long nativeCreateTransaction();
private static native long nativeGetNativeTransactionFinalizer();
@@ -1990,7 +1990,16 @@ public final class SurfaceControl implements Parcelable {
*/
public static ScreenshotGraphicBuffer captureLayers(IBinder layerHandleToken, Rect sourceCrop,
float frameScale) {
- return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale);
+ return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale, null);
+ }
+
+ /**
+ * Like {@link captureLayers} but with an array of layer handles to exclude.
+ * @hide
+ */
+ public static ScreenshotGraphicBuffer captureLayersExcluding(IBinder layerHandleToken,
+ Rect sourceCrop, float frameScale, IBinder[] exclude) {
+ return nativeCaptureLayers(layerHandleToken, sourceCrop, frameScale, exclude);
}
/**
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 94f96babaf90..3f50f39fb785 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -270,7 +270,7 @@ static jobject nativeScreenshot(JNIEnv* env, jclass clazz,
}
static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandleToken,
- jobject sourceCropObj, jfloat frameScale) {
+ jobject sourceCropObj, jfloat frameScale, jobjectArray excludeArray) {
sp<IBinder> layerHandle = ibinderForJavaObject(env, layerHandleToken);
if (layerHandle == NULL) {
@@ -282,11 +282,27 @@ static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandl
sourceCrop = rectFromObj(env, sourceCropObj);
}
+ std::unordered_set<sp<IBinder>,ISurfaceComposer::SpHash<IBinder>> excludeHandles;
+ if (excludeArray != NULL) {
+ const jsize len = env->GetArrayLength(excludeArray);
+ excludeHandles.reserve(len);
+
+ for (jsize i = 0; i < len; i++) {
+ jobject obj = env->GetObjectArrayElement(excludeArray, i);
+ if (obj == nullptr) {
+ jniThrowNullPointerException(env, "Exclude layer is null");
+ return NULL;
+ }
+ sp<IBinder> excludeHandle = ibinderForJavaObject(env, obj);
+ excludeHandles.emplace(excludeHandle);
+ }
+ }
+
sp<GraphicBuffer> buffer;
const ui::Dataspace dataspace = ui::Dataspace::V0_SRGB;
status_t res = ScreenshotClient::captureChildLayers(layerHandle, dataspace,
ui::PixelFormat::RGBA_8888, sourceCrop,
- frameScale, &buffer);
+ excludeHandles, frameScale, &buffer);
if (res != NO_ERROR) {
return NULL;
}
@@ -1354,7 +1370,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
"Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;",
(void*)nativeScreenshot },
{"nativeCaptureLayers",
- "(Landroid/os/IBinder;Landroid/graphics/Rect;F)"
+ "(Landroid/os/IBinder;Landroid/graphics/Rect;F[Landroid/os/IBinder;)"
"Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;",
(void*)nativeCaptureLayers },
{"nativeSetInputWindowInfo", "(JJLandroid/view/InputWindowHandle;)V",