// Adds listener and callbackIds in case there are no SurfaceControls that are supposed
// to be included in the callback. This functions should be call before attempting to register
// any callback handles.
status_t TransactionCallbackInvoker::startRegistration(const ListenerCallbacks& listenerCallbacks) {
std::lock_guard lock(mMutex);
auto [itr, inserted] = mRegisteringTransactions.insert(listenerCallbacks);
auto& [listener, callbackIds] = listenerCallbacks;
if (inserted) {
if (mCompletedTransactions.count(listener) == 0) {
status_t err = listener->linkToDeath(mDeathRecipient);
if (err != NO_ERROR) {
ALOGE("cannot add callback because linkToDeath failed, err: %d", err);
return err;
}
}
auto& transactionStatsDeque = mCompletedTransactions[listener];
transactionStatsDeque.emplace_back(callbackIds);
}
return NO_ERROR;
}