class ListenerCallbacks {
public:
ListenerCallbacks(const sp<IBinder>& listener,
const std::unordered_set<CallbackId, CallbackIdHash>& callbacks)
: transactionCompletedListener(listener),
callbackIds(callbacks.begin(), callbacks.end()) {}
ListenerCallbacks(const sp<IBinder>& listener, const std::vector<CallbackId>& ids)
: transactionCompletedListener(listener), callbackIds(ids) {}
bool operator==(const ListenerCallbacks& rhs) const {
if (transactionCompletedListener != rhs.transactionCompletedListener) {
return false;
}
if (callbackIds.empty()) {
return rhs.callbackIds.empty();
}
return callbackIds.front().id == rhs.callbackIds.front().id;
}
// Returns a new ListenerCallbacks filtered by type
ListenerCallbacks filter(CallbackId::Type type) const;
sp<IBinder> transactionCompletedListener;
std::vector<CallbackId> callbackIds;
};
transactionCompletedListener
是 ITransactionCompletedListener。callbackIds
是 CallbackId 向量。Transaction::mListenerCallbacks 是 ITransactionCompletedListener → CallbackInfo map。