Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 643423e4 authored by Evan Severson's avatar Evan Severson
Browse files

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
parent 1f700cd0
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -114,15 +114,14 @@ static bool checkRecordingInternal(const Identity& identity, const String16& msg
        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;