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

Commit f41f24f5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add appops for audio hardening" into main

parents 8741254a bd6ad4ca
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