Expose transaction id

We will need to dump the transaction id in transition traces to be able to reliably associated the start and end of a transition to the states in the SF trace.

Bug: 230462538
Test: N/A
Change-Id: I2a040503d9e1f4f4636549bae6b7fe12d5632049
This commit is contained in:
Pablo Gamito
2022-06-07 18:45:54 +00:00
parent dc1cde0d5d
commit 0ada73d3f5
2 changed files with 17 additions and 0 deletions

View File

@@ -121,6 +121,7 @@ public final class SurfaceControl implements Parcelable {
private static native void nativeSetAnimationTransaction(long transactionObj);
private static native void nativeSetEarlyWakeupStart(long transactionObj);
private static native void nativeSetEarlyWakeupEnd(long transactionObj);
private static native long nativeGetTransactionId(long transactionObj);
private static native void nativeSetLayer(long transactionObj, long nativeObject, int zorder);
private static native void nativeSetRelativeLayer(long transactionObj, long nativeObject,
@@ -3536,6 +3537,15 @@ public final class SurfaceControl implements Parcelable {
return this;
}
/**
* @hide
* @return The transaction's current id.
* The id changed every time the transaction is applied.
*/
public long getId() {
return nativeGetTransactionId(mNativeObject);
}
/**
* Sets an arbitrary piece of metadata on the surface. This is a helper for int data.
* @hide

View File

@@ -580,6 +580,11 @@ static void nativeSetEarlyWakeupEnd(JNIEnv* env, jclass clazz, jlong transaction
transaction->setEarlyWakeupEnd();
}
static jlong nativeGetTransactionId(JNIEnv* env, jclass clazz, jlong transactionObj) {
auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
return transaction->getId();
}
static void nativeSetLayer(JNIEnv* env, jclass clazz, jlong transactionObj,
jlong nativeObject, jint zorder) {
auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
@@ -2103,6 +2108,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
(void*)nativeSetEarlyWakeupStart },
{"nativeSetEarlyWakeupEnd", "(J)V",
(void*)nativeSetEarlyWakeupEnd },
{"nativeGetTransactionId", "(J)J",
(void*)nativeGetTransactionId },
{"nativeSetLayer", "(JJI)V",
(void*)nativeSetLayer },
{"nativeSetRelativeLayer", "(JJJI)V",