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

Commit 7500a8cf authored by Evan Severson's avatar Evan Severson
Browse files

Listen to active apps for virtual devices too

The older callback filters non-default devices so we want to be using
the newer callback for privacy indicators.

Fixes: 343048379
Bug: 382302116
Test: atest CameraMicIndicatorsPermissionTest AppOpsControllerTest
Flag: EXEMPT bugfix
Change-Id: Idc10d54ffacd084aec37ef46f731bd39c29df3c7
parent 18f0d02b
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -242,6 +242,7 @@ public class AppOpsControllerImpl extends BroadcastReceiver implements AppOpsCon
                                op.getUid(),
                                op.getPackageName(),
                                /* attributionTag= */ attributedOpEntry.getKey(),
                                Context.DEVICE_ID_DEFAULT,
                                /* active= */ true,
                                // AppOpsManager doesn't have a way to fetch attribution flags or
                                // chain ID given an op entry, so default them to none.
@@ -440,14 +441,14 @@ public class AppOpsControllerImpl extends BroadcastReceiver implements AppOpsCon
     * Required to override, delegate to other. Should not be called.
     */
    public void onOpActiveChanged(String op, int uid, String packageName, boolean active) {
        onOpActiveChanged(op, uid, packageName, null, active,
        onOpActiveChanged(op, uid, packageName, null, Context.DEVICE_ID_DEFAULT, active,
                AppOpsManager.ATTRIBUTION_FLAGS_NONE, AppOpsManager.ATTRIBUTION_CHAIN_ID_NONE);
    }

    // Get active app ops, and check if their attributions are trusted
    @Override
    public void onOpActiveChanged(String op, int uid, String packageName, String attributionTag,
            boolean active, int attributionFlags, int attributionChainId) {
            int virtualDeviceId, boolean active, int attributionFlags, int attributionChainId) {
        int code = AppOpsManager.strOpToOp(op);
        if (DEBUG) {
            Log.w(TAG, String.format("onActiveChanged(%d,%d,%s,%s,%d,%d)", code, uid, packageName,
+5 −4
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.app.AppOpsManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.media.AudioRecordingConfiguration;
@@ -593,11 +594,11 @@ public class AppOpsControllerTest extends SysuiTestCase {

        //untrusted receiver access
        mController.onOpActiveChanged(AppOpsManager.OPSTR_RECORD_AUDIO, TEST_UID,
                TEST_PACKAGE_NAME, TEST_ATTRIBUTION_NAME, true,
                TEST_PACKAGE_NAME, TEST_ATTRIBUTION_NAME, Context.DEVICE_ID_DEFAULT, true,
                AppOpsManager.ATTRIBUTION_FLAG_RECEIVER, TEST_CHAIN_ID);
        //untrusted intermediary access
        mController.onOpActiveChanged(AppOpsManager.OPSTR_RECORD_AUDIO, TEST_UID,
                TEST_PACKAGE_NAME, TEST_ATTRIBUTION_NAME, true,
                TEST_PACKAGE_NAME, TEST_ATTRIBUTION_NAME, Context.DEVICE_ID_DEFAULT, true,
                AppOpsManager.ATTRIBUTION_FLAG_INTERMEDIARY, TEST_CHAIN_ID);
        assertTrue(mController.getActiveAppOps().isEmpty());
    }
@@ -606,11 +607,11 @@ public class AppOpsControllerTest extends SysuiTestCase {
    public void testTrustedChainUsagesKept() {
        //untrusted accessor access
        mController.onOpActiveChanged(AppOpsManager.OPSTR_RECORD_AUDIO, TEST_UID,
                TEST_PACKAGE_NAME, TEST_ATTRIBUTION_NAME, true,
                TEST_PACKAGE_NAME, TEST_ATTRIBUTION_NAME, Context.DEVICE_ID_DEFAULT, true,
                AppOpsManager.ATTRIBUTION_FLAG_ACCESSOR, TEST_CHAIN_ID);
        //trusted access
        mController.onOpActiveChanged(AppOpsManager.OPSTR_CAMERA, TEST_UID,
                TEST_PACKAGE_NAME, TEST_ATTRIBUTION_NAME, true,
                TEST_PACKAGE_NAME, TEST_ATTRIBUTION_NAME, Context.DEVICE_ID_DEFAULT, true,
                AppOpsManager.ATTRIBUTION_FLAG_RECEIVER | AppOpsManager.ATTRIBUTION_FLAG_TRUSTED,
                TEST_CHAIN_ID);
        assertEquals(2, mController.getActiveAppOps().size());