Binder count in audioserver will increase more and more when recording.
AudioPolicy will use startRecording/stopRecording in startInput,stopInput
function and resolveAttributionSource function will make a new binder each time
for start/finish recording.
The new binder, which create in startRecording, will be held in
PermissionManagerService and couldn't be remove when finishRecording,because
finishRecording also make another new binder instance.
we should make binder use the same instance when use startRecording and
stopRecording.
Test: AudioRecord
Bug: 205058577
Change-Id: I5e36b3063c2c89e72654acdac2cfb736de579f01
diff --git a/media/utils/ServiceUtilities.cpp b/media/utils/ServiceUtilities.cpp
index 9c7b863..42f48a5 100644
--- a/media/utils/ServiceUtilities.cpp
+++ b/media/utils/ServiceUtilities.cpp
@@ -101,7 +101,11 @@
AttributionSourceState myAttributionSource;
myAttributionSource.uid = VALUE_OR_FATAL(android::legacy2aidl_uid_t_int32_t(getuid()));
myAttributionSource.pid = VALUE_OR_FATAL(android::legacy2aidl_pid_t_int32_t(getpid()));
- myAttributionSource.token = sp<BBinder>::make();
+ if (callerAttributionSource.token != nullptr) {
+ myAttributionSource.token = callerAttributionSource.token;
+ } else {
+ myAttributionSource.token = sp<BBinder>::make();
+ }
myAttributionSource.next.push_back(nextAttributionSource);
return std::optional<AttributionSourceState>{myAttributionSource};