Allow creating and starting of AudioRecord if appop is ignored
According to the documentation MODE_IGNORED is supposed to cause a
silent failure so in this case we want to successfully create and start
the recording but the difference between this an MODE_ALLOWED is that
the audio content should be silenced.
Test: Install sdk 22 app, revoke permission, observe no more crash
Observe GCA doesn't crash anymore when trying to record a video
using the microphone toggle
atest NoAudioPermissionTest AudioRecordAppOpTest AudioRecordAppOpTest
atest audiopolicy_tests
Fixes: 185939466
Change-Id: I6e6c6ab36c597bdf0f71f28fe6350f83d4ccb601
diff --git a/media/utils/ServiceUtilities.cpp b/media/utils/ServiceUtilities.cpp
index e2e1043..669b565 100644
--- a/media/utils/ServiceUtilities.cpp
+++ b/media/utils/ServiceUtilities.cpp
@@ -114,15 +114,14 @@
if (int32_t mode = appOps.startOpNoThrow(op, identity.uid,
resolvedOpPackageName, /*startIfModeDefault*/ false,
VALUE_OR_FATAL(aidl2legacy_optional_string_view_optional_String16(
- identity.attributionTag)), msg) != AppOpsManager::MODE_ALLOWED) {
+ identity.attributionTag)), msg) == AppOpsManager::MODE_ERRORED) {
ALOGE("Request start for \"%s\" (uid %d) denied by app op: %d, mode: %d",
String8(resolvedOpPackageName).c_str(), identity.uid, op, mode);
return false;
}
} else {
- // Always use OP_RECORD_AUDIO for checks at creation time.
if (int32_t mode = appOps.checkOp(op, uid,
- resolvedOpPackageName) != AppOpsManager::MODE_ALLOWED) {
+ resolvedOpPackageName) == AppOpsManager::MODE_ERRORED) {
ALOGE("Request check for \"%s\" (uid %d) denied by app op: %d, mode: %d",
String8(resolvedOpPackageName).c_str(), identity.uid, op, mode);
return false;