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

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

Merge "Permission enforcement for A11y volume changes"

parents 300392ec ab2d9315
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -180,6 +180,9 @@
    <!-- accessibility -->
    <uses-permission android:name="android.permission.MODIFY_ACCESSIBILITY_DATA" />

    <!-- to control accessibility volume -->
    <uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />

    <application
        android:name=".SystemUIApplication"
        android:persistent="true"
+14 −0
Original line number Diff line number Diff line
@@ -1241,6 +1241,13 @@ public class AudioService extends IAudioService.Stub
    /** @see AudioManager#adjustStreamVolume(int, int, int) */
    public void adjustStreamVolume(int streamType, int direction, int flags,
            String callingPackage) {
        if ( streamType == AudioManager.STREAM_ACCESSIBILITY
                && (PackageManager.PERMISSION_GRANTED != mContext.checkCallingOrSelfPermission(
                        android.Manifest.permission.BIND_ACCESSIBILITY_SERVICE))) {
            Log.w(TAG, "Trying to call adjustStreamVolume() for a11y without"
                    + "BIND_ACCESSIBILITY_SERVICE / callingPackage=" + callingPackage);
            return;
        }
        adjustStreamVolume(streamType, direction, flags, callingPackage, callingPackage,
                Binder.getCallingUid());
    }
@@ -1552,6 +1559,13 @@ public class AudioService extends IAudioService.Stub

    /** @see AudioManager#setStreamVolume(int, int, int) */
    public void setStreamVolume(int streamType, int index, int flags, String callingPackage) {
        if ( streamType == AudioManager.STREAM_ACCESSIBILITY
                && (PackageManager.PERMISSION_GRANTED != mContext.checkCallingOrSelfPermission(
                        android.Manifest.permission.BIND_ACCESSIBILITY_SERVICE))) {
            Log.w(TAG, "Trying to call setStreamVolume() for a11y without"
                    + " BIND_ACCESSIBILITY_SERVICE  callingPackage=" + callingPackage);
            return;
        }
        setStreamVolume(streamType, index, flags, callingPackage, callingPackage,
                Binder.getCallingUid());
    }