Add origin PID and UID to queued transactions
Allows us to record the transaction origin when transaction queues are flushed by the main thread
Test: N/A
Change-Id: Ie31da48e4928883c3d9023f6c0c7d682ab9b3412
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index d1feada..758e46e 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3300,8 +3300,8 @@
mPendingInputWindowCommands, transaction.desiredPresentTime,
transaction.buffer, transaction.postTime,
transaction.privileged, transaction.hasListenerCallbacks,
- transaction.listenerCallbacks, /*originPID*/ -1,
- /*originUID*/ -1, /*isMainThread*/ true);
+ transaction.listenerCallbacks, transaction.originPID,
+ transaction.originUID, /*isMainThread*/ true);
transactionQueue.pop();
flushedATransaction = true;
}
@@ -3381,18 +3381,19 @@
mExpectedPresentTime = calculateExpectedPresentTime(systemTime());
}
- if (pendingTransactions || !transactionIsReadyToBeApplied(desiredPresentTime, states)) {
- mTransactionQueues[applyToken].emplace(states, displays, flags, desiredPresentTime,
- uncacheBuffer, postTime, privileged,
- hasListenerCallbacks, listenerCallbacks);
- setTransactionFlags(eTransactionFlushNeeded);
- return;
- }
-
IPCThreadState* ipc = IPCThreadState::self();
const int originPID = ipc->getCallingPid();
const int originUID = ipc->getCallingUid();
+ if (pendingTransactions || !transactionIsReadyToBeApplied(desiredPresentTime, states)) {
+ mTransactionQueues[applyToken].emplace(states, displays, flags, desiredPresentTime,
+ uncacheBuffer, postTime, privileged,
+ hasListenerCallbacks, listenerCallbacks, originPID,
+ originUID);
+ setTransactionFlags(eTransactionFlushNeeded);
+ return;
+ }
+
applyTransactionState(states, displays, flags, inputWindowCommands, desiredPresentTime,
uncacheBuffer, postTime, privileged, hasListenerCallbacks,
listenerCallbacks, originPID, originUID, /*isMainThread*/ false);
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 02385f9..8601318 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -1140,7 +1140,8 @@
const Vector<DisplayState>& displayStates, uint32_t transactionFlags,
int64_t desiredPresentTime, const client_cache_t& uncacheBuffer,
int64_t postTime, bool privileged, bool hasListenerCallbacks,
- std::vector<ListenerCallbacks> listenerCallbacks)
+ std::vector<ListenerCallbacks> listenerCallbacks, int originPID,
+ int originUID)
: states(composerStates),
displays(displayStates),
flags(transactionFlags),
@@ -1149,7 +1150,9 @@
postTime(postTime),
privileged(privileged),
hasListenerCallbacks(hasListenerCallbacks),
- listenerCallbacks(listenerCallbacks) {}
+ listenerCallbacks(listenerCallbacks),
+ originPID(originPID),
+ originUID(originUID) {}
Vector<ComposerState> states;
Vector<DisplayState> displays;
@@ -1160,6 +1163,8 @@
bool privileged;
bool hasListenerCallbacks;
std::vector<ListenerCallbacks> listenerCallbacks;
+ int originPID;
+ int originUID;
};
std::unordered_map<sp<IBinder>, std::queue<TransactionState>, IListenerHash> mTransactionQueues;