Add attributionTag to audio-recordings
... by replacing packageName/uid/pid by the Identity class.
This allows us to track which parts of the app trigger audio-recordings.
90% of the code is just sending around the additional parameters.
This adds it for the Java and native API.
Test: atest CtsAppOpsTestCases
CtsNativeMediaAAudioTestCases
Fixes: 160150145
Change-Id: Ibd7b884f7fcd4668a4e27f997e59cfc3217a9e89
diff --git a/media/utils/fuzzers/Android.bp b/media/utils/fuzzers/Android.bp
index 80882b2..187ef7c 100644
--- a/media/utils/fuzzers/Android.bp
+++ b/media/utils/fuzzers/Android.bp
@@ -15,6 +15,7 @@
"liblog",
"libmediautils",
"libutils",
+ "media_permission-aidl-cpp",
],
cflags: [
diff --git a/media/utils/fuzzers/ServiceUtilitiesFuzz.cpp b/media/utils/fuzzers/ServiceUtilitiesFuzz.cpp
index f4c815c..2f9e780 100644
--- a/media/utils/fuzzers/ServiceUtilitiesFuzz.cpp
+++ b/media/utils/fuzzers/ServiceUtilitiesFuzz.cpp
@@ -19,12 +19,15 @@
#include <functional>
#include <type_traits>
+#include <android/media/permission/Identity.h>
#include "fuzzer/FuzzedDataProvider.h"
#include "mediautils/ServiceUtilities.h"
static constexpr int kMaxOperations = 50;
static constexpr int kMaxStringLen = 256;
+using android::media::permission::Identity;
+
const std::vector<std::function<void(FuzzedDataProvider*, android::MediaPackageManager)>>
operations = {
[](FuzzedDataProvider* data_provider, android::MediaPackageManager pm) -> void {
@@ -43,27 +46,33 @@
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
FuzzedDataProvider data_provider(data, size);
- uid_t uid = data_provider.ConsumeIntegral<uid_t>();
- pid_t pid = data_provider.ConsumeIntegral<pid_t>();
+ int32_t uid = data_provider.ConsumeIntegral<int32_t>();
+ int32_t pid = data_provider.ConsumeIntegral<int32_t>();
audio_source_t source = static_cast<audio_source_t>(data_provider
.ConsumeIntegral<std::underlying_type_t<audio_source_t>>());
+ std::string packageNameStr = data_provider.ConsumeRandomLengthString(kMaxStringLen);
+ std::string msgStr = data_provider.ConsumeRandomLengthString(kMaxStringLen);
+ android::String16 msgStr16(packageNameStr.c_str());
+ Identity identity;
+ identity.packageName = packageNameStr;
+ identity.uid = uid;
+ identity.pid = pid;
+
// There is not state here, and order is not significant,
// so we can simply call all of the target functions
android::isServiceUid(uid);
android::isAudioServerUid(uid);
android::isAudioServerOrSystemServerUid(uid);
android::isAudioServerOrMediaServerUid(uid);
- std::string packageNameStr = data_provider.ConsumeRandomLengthString(kMaxStringLen);
- android::String16 opPackageName(packageNameStr.c_str());
- android::recordingAllowed(opPackageName, pid, uid);
- android::startRecording(opPackageName, pid, uid, source);
- android::finishRecording(opPackageName, uid, source);
- android::captureAudioOutputAllowed(pid, uid);
- android::captureMediaOutputAllowed(pid, uid);
- android::captureHotwordAllowed(opPackageName, pid, uid);
- android::modifyPhoneStateAllowed(uid, pid);
- android::bypassInterruptionPolicyAllowed(uid, pid);
+ android::recordingAllowed(identity);
+ android::startRecording(identity, msgStr16, source);
+ android::finishRecording(identity, source);
+ android::captureAudioOutputAllowed(identity);
+ android::captureMediaOutputAllowed(identity);
+ android::captureHotwordAllowed(identity);
+ android::modifyPhoneStateAllowed(identity);
+ android::bypassInterruptionPolicyAllowed(identity);
android::settingsAllowed();
android::modifyAudioRoutingAllowed();
android::modifyDefaultAudioEffectsAllowed();