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

Commit 269acb4c authored by Eric Laurent's avatar Eric Laurent
Browse files

audio: add command to purge permission cache

Add a media_audio_policy service command and helper function
in ServiceUtilities to purge permission cache.

This permists to restore the use of permission cache for
CAPTURE_AUDIO_HOTWORD permission while still  allowing CTS tests to
adopt shell permission.

Bug: 185972521
Test: atest AudioRecordSharedAudioTest
Change-Id: Ib8963053d6d7734e474174f572762abe1a4be13b
parent 6fea7f00
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -212,10 +212,7 @@ bool captureHotwordAllowed(const Identity& identity) {

    if (ok) {
        static const String16 sCaptureHotwordAllowed("android.permission.CAPTURE_AUDIO_HOTWORD");
        //TODO: b/185972521: see if permission cache can be used with shell identity for CTS
        PermissionController permissionController;
        ok = permissionController.checkPermission(sCaptureHotwordAllowed,
            pid, uid);
        ok = PermissionCache::checkPermission(sCaptureHotwordAllowed, pid, uid);
    }
    if (!ok) ALOGV("android.permission.CAPTURE_AUDIO_HOTWORD");
    return ok;
@@ -301,6 +298,10 @@ Identity getCallingIdentity() {
  return identity;
}

void purgePermissionCache() {
    PermissionCache::purgeCache();
}

status_t checkIMemory(const sp<IMemory>& iMemory)
{
    if (iMemory == 0) {
+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ bool modifyDefaultAudioEffectsAllowed(const media::permission::Identity& identit
bool dumpAllowed();
bool modifyPhoneStateAllowed(const media::permission::Identity& identity);
bool bypassInterruptionPolicyAllowed(const media::permission::Identity& identity);
void purgePermissionCache();

media::permission::Identity getCallingIdentity();

+3 −0
Original line number Diff line number Diff line
@@ -1019,6 +1019,9 @@ status_t AudioPolicyService::shellCommand(int in, int out, int err, Vector<Strin
        return handleResetUidState(args, err);
    } else if (args.size() >= 2 && args[0] == String16("get-uid-state")) {
        return handleGetUidState(args, out, err);
    } else if (args.size() >= 1 && args[0] == String16("purge_permission-cache")) {
        purgePermissionCache();
        return NO_ERROR;
    } else if (args.size() == 1 && args[0] == String16("help")) {
        printHelp(out);
        return NO_ERROR;