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

Commit c5db4bfb authored by Emily Bernier's avatar Emily Bernier Committed by Android (Google) Code Review
Browse files

Merge "Add an app ops code for microphone muting."

parents 90c91c2a 22c921a9
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -189,7 +189,9 @@ public class AppOpsManager {
    /** @hide Retrieve current usage stats via {@link UsageStatsManager}. */
    public static final int OP_GET_USAGE_STATS = 43;
    /** @hide */
    public static final int _NUM_OP = 44;
    public static final int OP_MUTE_MICROPHONE = 44;
    /** @hide */
    public static final int _NUM_OP = 45;

    /** Access to coarse location information. */
    public static final String OPSTR_COARSE_LOCATION =
@@ -257,6 +259,7 @@ public class AppOpsManager {
            OP_COARSE_LOCATION,
            OP_COARSE_LOCATION,
            OP_GET_USAGE_STATS,
            OP_MUTE_MICROPHONE
    };

    /**
@@ -308,6 +311,7 @@ public class AppOpsManager {
            OPSTR_MONITOR_LOCATION,
            OPSTR_MONITOR_HIGH_POWER_LOCATION,
            null,
            null,
    };

    /**
@@ -358,7 +362,8 @@ public class AppOpsManager {
            "WAKE_LOCK",
            "MONITOR_LOCATION",
            "MONITOR_HIGH_POWER_LOCATION",
            "GET_USAGE_STATS"
            "GET_USAGE_STATS",
            "OP_MUTE_MICROPHONE",
    };

    /**
@@ -410,6 +415,7 @@ public class AppOpsManager {
            null, // no permission for generic location monitoring
            null, // no permission for high power location monitoring
            android.Manifest.permission.PACKAGE_USAGE_STATS,
            null, // no permission for muting/unmuting microphone
    };

    /**
@@ -462,6 +468,7 @@ public class AppOpsManager {
            null, //MONITOR_LOCATION
            null, //MONITOR_HIGH_POWER_LOCATION
            null, //GET_USAGE_STATS
            UserManager.DISALLOW_UNMUTE_MICROPHONE, // MUTE_MICROPHONE
    };

    /**
@@ -512,6 +519,7 @@ public class AppOpsManager {
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_ALLOWED,
            AppOpsManager.MODE_IGNORED, // OP_GET_USAGE_STATS
            AppOpsManager.MODE_ALLOWED,
    };

    /**
@@ -566,6 +574,7 @@ public class AppOpsManager {
            false,
            false,
            false,
            false,
    };

    private static HashMap<String, Integer> sOpStrToOp = new HashMap<String, Integer>();
+6 −1
Original line number Diff line number Diff line
@@ -1425,7 +1425,12 @@ public class AudioManager {
     *           <var>false</var> to turn mute off
     */
    public void setMicrophoneMute(boolean on){
        AudioSystem.muteMicrophone(on);
        IAudioService service = getService();
        try {
            service.setMicrophoneMute(on, mContext.getOpPackageName());
        } catch (RemoteException e) {
            Log.e(TAG, "Dead object in setMicrophoneMute", e);
        }
    }

    /**
+10 −0
Original line number Diff line number Diff line
@@ -1437,6 +1437,16 @@ public class AudioService extends IAudioService.Stub {
        }
    }

    /** @see AudioManager#setMicrophoneMute(boolean) */
    public void setMicrophoneMute(boolean on, String callingPackage) {
        if (mAppOps.noteOp(AppOpsManager.OP_MUTE_MICROPHONE, Binder.getCallingUid(),
                callingPackage) != AppOpsManager.MODE_ALLOWED) {
            return;
        }

        AudioSystem.muteMicrophone(on);
    }

    /** @see AudioManager#getRingerMode() */
    public int getRingerMode() {
        synchronized(mSettingsLock) {
+2 −0
Original line number Diff line number Diff line
@@ -78,6 +78,8 @@ interface IAudioService {

    int getLastAudibleMasterVolume();

    void setMicrophoneMute(boolean on, String callingPackage);

    void setRingerMode(int ringerMode);

    int getRingerMode();