summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/SurfaceControl.java33
-rw-r--r--core/jni/android_view_SurfaceControl.cpp6
2 files changed, 32 insertions, 7 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index 1cd7d349a9af..cc8dd079a80f 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -47,6 +47,7 @@ import android.graphics.Rect;
import android.graphics.Region;
import android.gui.DropInputMode;
import android.gui.StalledTransactionInfo;
+import android.gui.TrustedOverlay;
import android.hardware.DataSpace;
import android.hardware.HardwareBuffer;
import android.hardware.OverlayProperties;
@@ -165,7 +166,7 @@ public final class SurfaceControl implements Parcelable {
float maxStretchAmountX, float maxStretchAmountY, float childRelativeLeft,
float childRelativeTop, float childRelativeRight, float childRelativeBottom);
private static native void nativeSetTrustedOverlay(long transactionObj, long nativeObject,
- boolean isTrustedOverlay);
+ int isTrustedOverlay);
private static native void nativeSetDropInputMode(
long transactionObj, long nativeObject, int flags);
private static native void nativeSetCanOccludePresentation(long transactionObj,
@@ -4303,13 +4304,37 @@ public final class SurfaceControl implements Parcelable {
}
/**
- * Sets the trusted overlay state on this SurfaceControl and it is inherited to all the
- * children. The caller must hold the ACCESS_SURFACE_FLINGER permission.
+ * @see Transaction#setTrustedOverlay(SurfaceControl, int)
* @hide
*/
public Transaction setTrustedOverlay(SurfaceControl sc, boolean isTrustedOverlay) {
+ return setTrustedOverlay(sc,
+ isTrustedOverlay ? TrustedOverlay.ENABLED : TrustedOverlay.UNSET);
+ }
+
+ /**
+ * Trusted overlay state prevents SurfaceControl from being considered as obscuring for
+ * input occlusion detection purposes. The caller must hold the
+ * ACCESS_SURFACE_FLINGER permission. See {@code TrustedOverlay}.
+ * <p>
+ * Arguments:
+ * {@code TrustedOverlay.UNSET} - The default value, SurfaceControl will inherit the state
+ * from its parents. If the parent state is also {@code TrustedOverlay.UNSET}, the layer
+ * will be considered as untrusted.
+ * <p>
+ * {@code TrustedOverlay.DISABLED} - Treats this SurfaceControl and all its children as an
+ * untrusted overlay. This will override any state set by its parent SurfaceControl.
+ * <p>
+ * {@code TrustedOverlay.ENABLED} - Treats this SurfaceControl and all its children as a
+ * trusted overlay unless the child SurfaceControl explicitly disables its trusted state
+ * via {@code TrustedOverlay.DISABLED}.
+ * <p>
+ * @hide
+ */
+ public Transaction setTrustedOverlay(SurfaceControl sc,
+ @TrustedOverlay int trustedOverlay) {
checkPreconditions(sc);
- nativeSetTrustedOverlay(mNativeObject, sc.mNativeObject, isTrustedOverlay);
+ nativeSetTrustedOverlay(mNativeObject, sc.mNativeObject, trustedOverlay);
return this;
}
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 1aa635c6ceb7..de059dbb8d0d 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -1008,11 +1008,11 @@ static void nativeSetShadowRadius(JNIEnv* env, jclass clazz, jlong transactionOb
}
static void nativeSetTrustedOverlay(JNIEnv* env, jclass clazz, jlong transactionObj,
- jlong nativeObject, jboolean isTrustedOverlay) {
+ jlong nativeObject, jint trustedOverlay) {
auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
- transaction->setTrustedOverlay(ctrl, isTrustedOverlay);
+ transaction->setTrustedOverlay(ctrl, static_cast<gui::TrustedOverlay>(trustedOverlay));
}
static void nativeSetFrameRate(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject,
@@ -2443,7 +2443,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
(void*)nativeSetTransformHint },
{"nativeGetTransformHint", "(J)I",
(void*)nativeGetTransformHint },
- {"nativeSetTrustedOverlay", "(JJZ)V",
+ {"nativeSetTrustedOverlay", "(JJI)V",
(void*)nativeSetTrustedOverlay },
{"nativeGetLayerId", "(J)I",
(void*)nativeGetLayerId },