summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vishnu Nair <vishnun@google.com> 2022-08-11 16:32:53 -0700
committer Evan Rosky <erosky@google.com> 2022-08-16 18:20:33 +0000
commitf82e53bfc37bbec85c0623801694c23b36a9c288 (patch)
tree4e774e8e62c714c28e5ace01309e7790d189c485
parent3e348ff74dc07e0def733edcf022dc71ca64f99e (diff)
SurfaceComposerClient: Expose default apply token
The default apply token specifies which transaction queue transactions from a process is sent to in surfaceflinger. This queue is used to ensure transactions from a process are applied in order. If a transaction from multiple processes need to be applied in order, we can use a commit callback to act as a barrier or pass transactions across processes to be applied on a single process. In some cases where operations are intertwined it may be advantageous to set a single transaction queue for multiple processes. In this case this api can be used to set a single queue to apply transactions by setting the same apply token on both processes. Note this api if misused can result in surprising out of order transactions. Test: manually set the same applytoken on multiple processes and verify they go into the same queue. Bug: 242193885 Change-Id: I507b44686b393c1bb854bd593535a3a3874497af
-rw-r--r--core/java/android/view/SurfaceControl.java19
-rw-r--r--core/jni/android_view_SurfaceControl.cpp18
2 files changed, 37 insertions, 0 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index 84f04c12cf51..e48140066837 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -274,6 +274,9 @@ public final class SurfaceControl implements Parcelable {
private static native void nativeSanitize(long transactionObject);
private static native void nativeSetDestinationFrame(long transactionObj, long nativeObject,
int l, int t, int r, int b);
+ private static native void nativeSetDefaultApplyToken(IBinder token);
+ private static native IBinder nativeGetDefaultApplyToken();
+
/**
* Transforms that can be applied to buffers as they are displayed to a window.
@@ -2774,6 +2777,22 @@ public final class SurfaceControl implements Parcelable {
}
/**
+ *
+ * @hide
+ */
+ public static void setDefaultApplyToken(IBinder token) {
+ nativeSetDefaultApplyToken(token);
+ }
+
+ /**
+ *
+ * @hide
+ */
+ public static IBinder getDefaultApplyToken() {
+ return nativeGetDefaultApplyToken();
+ }
+
+ /**
* Apply the transaction, clearing it's state, and making it usable
* as a new transaction.
*/
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 9ae16304b6c8..7107458a166d 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -2121,6 +2121,20 @@ static jint nativeGetLayerId(JNIEnv* env, jclass clazz, jlong nativeSurfaceContr
return surface->getLayerId();
}
+static void nativeSetDefaultApplyToken(JNIEnv* env, jclass clazz, jobject applyToken) {
+ sp<IBinder> token(ibinderForJavaObject(env, applyToken));
+ if (token == nullptr) {
+ ALOGE("Null apply token provided.");
+ return;
+ }
+ SurfaceComposerClient::Transaction::setDefaultApplyToken(token);
+}
+
+static jobject nativeGetDefaultApplyToken(JNIEnv* env, jclass clazz) {
+ sp<IBinder> token = SurfaceComposerClient::Transaction::getDefaultApplyToken();
+ return javaObjectForIBinder(env, token);
+}
+
// ----------------------------------------------------------------------------
static const JNINativeMethod sSurfaceControlMethods[] = {
@@ -2343,6 +2357,10 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
(void*) nativeSanitize },
{"nativeSetDestinationFrame", "(JJIIII)V",
(void*)nativeSetDestinationFrame },
+ {"nativeSetDefaultApplyToken", "(Landroid/os/IBinder;)V",
+ (void*)nativeSetDefaultApplyToken },
+ {"nativeGetDefaultApplyToken", "()Landroid/os/IBinder;",
+ (void*)nativeGetDefaultApplyToken },
// clang-format on
};