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

Commit bd6ad4ca authored by Atneya Nair's avatar Atneya Nair
Browse files

Add appops for audio hardening

Add two internal appops associated with audio hardening work.

OP_CONTROL_AUDIO is the primary op, which will be associated with a
capability.  OP_CONTROL_AUDIO_PARTIAL is the secondary op, which will is
FOREGROUND without a capability.

OP_CONTROL_AUDIO may eventually be exposed in the special app access
menu in settings.

The implementation will be flagged rather than the definition since
these are not APIs.

Test: atest AppOpsDefinitionTest
Bug: 376480814
Flag: com.android.media.audio.hardening_impl
Change-Id: I69a5cae3a37968176198c938f9a5077e7750d595
parent a62258de
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -1628,9 +1628,15 @@ public class AppOpsManager {
    public static final int OP_WRITE_SYSTEM_PREFERENCES =
            AppOpEnums.APP_OP_WRITE_SYSTEM_PREFERENCES;

    /** @hide Access to audio playback and control APIs. */
    public static final int OP_CONTROL_AUDIO = AppOpEnums.APP_OP_CONTROL_AUDIO;

    /** @hide Similar to {@link OP_CONTROL_AUDIO}, but doesn't require capabilities. */
    public static final int OP_CONTROL_AUDIO_PARTIAL = AppOpEnums.APP_OP_CONTROL_AUDIO_PARTIAL;

    /** @hide */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    public static final int _NUM_OP = 154;
    public static final int _NUM_OP = 156;

    /**
     * All app ops represented as strings.
@@ -1788,6 +1794,8 @@ public class AppOpsManager {
            OPSTR_RANGING,
            OPSTR_READ_OXYGEN_SATURATION,
            OPSTR_WRITE_SYSTEM_PREFERENCES,
            OPSTR_CONTROL_AUDIO,
            OPSTR_CONTROL_AUDIO_PARTIAL,
    })
    public @interface AppOpString {}

@@ -2548,6 +2556,12 @@ public class AppOpsManager {
    /** @hide Access to system preferences write services */
    public static final String OPSTR_WRITE_SYSTEM_PREFERENCES = "android:write_system_preferences";

    /** @hide Access to audio playback and control APIs */
    public static final String OPSTR_CONTROL_AUDIO = "android:control_audio";

    /** @hide Access to a audio playback and control APIs without capability requirements */
    public static final String OPSTR_CONTROL_AUDIO_PARTIAL = "android:control_audio_partial";

    /** {@link #sAppOpsToNote} not initialized yet for this op */
    private static final byte SHOULD_COLLECT_NOTE_OP_NOT_INITIALIZED = 0;
    /** Should not collect noting of this app-op in {@link #sAppOpsToNote} */
@@ -3157,6 +3171,10 @@ public class AppOpsManager {
            "WRITE_SYSTEM_PREFERENCES").setPermission(
                     com.android.settingslib.flags.Flags.writeSystemPreferencePermissionEnabled()
                     ? Manifest.permission.WRITE_SYSTEM_PREFERENCES : null).build(),
        new AppOpInfo.Builder(OP_CONTROL_AUDIO, OPSTR_CONTROL_AUDIO,
                "CONTROL_AUDIO").setDefaultMode(AppOpsManager.MODE_FOREGROUND).build(),
        new AppOpInfo.Builder(OP_CONTROL_AUDIO_PARTIAL, OPSTR_CONTROL_AUDIO_PARTIAL,
                "CONTROL_AUDIO_PARTIAL").setDefaultMode(AppOpsManager.MODE_FOREGROUND).build(),
    };

    // The number of longs needed to form a full bitmask of app ops