second.size() == 0) { mPendingTransactions.erase(listener); } } else { ALOGW("cannot find listener in mP"> second.size() == 0) { mPendingTransactions.erase(listener); } } else { ALOGW("cannot find listener in mP"> second.size() == 0) { mPendingTransactions.erase(listener); } } else { ALOGW("cannot find listener in mP">
status_t TransactionCallbackInvoker::finalizeCallbackHandle(const sp<CallbackHandle>& handle,
const std::vector<JankData>& jankData) {
auto listener = mPendingTransactions.find(handle->listener);
if (listener != mPendingTransactions.end()) {
auto& pendingCallbacks = listener->second;
auto pendingCallback = pendingCallbacks.find(handle->callbackIds);
if (pendingCallback != pendingCallbacks.end()) {
auto& pendingCount = pendingCallback->second;
// Decrease the pending count for this listener
if (--pendingCount == 0) {
pendingCallbacks.erase(pendingCallback);
}
} else {
ALOGW("there are more latched callbacks than there were registered callbacks");
}
if (listener->second.size() == 0) {
mPendingTransactions.erase(listener);
}
} else {
ALOGW("cannot find listener in mPendingTransactions");
}
status_t err = addCallbackHandle(handle, jankData);
if (err != NO_ERROR) {
ALOGE("could not add callback handle");
return err;
}
return NO_ERROR;
}
listener
从 mPendingTransactions
中查找。pendingCallbacks
的类型是 std::unordered_map<std::vector<CallbackId>, uint32_t /*count*/, CallbackIdsHash>
。pendingCallbacks
再查找,获取 pendingCount
。pendingCount
减一,减完如果是 0,从 pendingCallbacks
中移除。handle
从 mCompletedTransactions
从查找 TransactionStats,更新它的 SurfaceStats。