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

Commit 497b3fe7 authored by Eric Laurent's avatar Eric Laurent
Browse files

Issue 5081351: isWiredHeadsetOn() permission.

AudioManager.isWiredHeadsetOn() should not require permission MODIFY_AUDIO_SETTINGS.
Remove permission checks on all getters in audio policy manager as permission enforcement
is really usefull for setters.
Also deprecate AudioManager.isWiredHeadsetOn() which name and implementation are deceptive.

Change-Id: I38f8df7c26c0d417bf0e2b74e4c11c2d143f2ecd
parent 7b53848d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10253,7 +10253,7 @@ package android.media {
    method public boolean isMicrophoneMute();
    method public boolean isMusicActive();
    method public boolean isSpeakerphoneOn();
    method public boolean isWiredHeadsetOn();
    method public deprecated boolean isWiredHeadsetOn();
    method public void loadSoundEffects();
    method public void playSoundEffect(int);
    method public void playSoundEffect(int, float);
+5 −2
Original line number Diff line number Diff line
@@ -1061,10 +1061,13 @@ public class AudioManager {
    }

    /**
     * Checks whether audio routing to the wired headset is on or off.
     * Checks whether a wired headset is connected or not.
     * <p>This is not a valid indication that audio playback is
     * actually over the wired headset as audio routing depends on other conditions.
     *
     * @return true if audio is being routed to/from wired headset;
     * @return true if a wired headset is connected.
     *         false if otherwise
     * @deprecated Use only to check is a headset is connected or not.
     */
    public boolean isWiredHeadsetOn() {
        if (AudioSystem.getDeviceConnectionState(DEVICE_OUT_WIRED_HEADSET,"")
+0 −9
Original line number Diff line number Diff line
@@ -182,9 +182,6 @@ audio_policy_dev_state_t AudioPolicyService::getDeviceConnectionState(
    if (mpAudioPolicy == NULL) {
        return AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;
    }
    if (!checkPermission()) {
        return AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE;
    }
    return mpAudioPolicy->get_device_connection_state(mpAudioPolicy, device,
                                                      device_address);
}
@@ -250,9 +247,6 @@ audio_policy_forced_cfg_t AudioPolicyService::getForceUse(audio_policy_force_use
    if (mpAudioPolicy == NULL) {
        return AUDIO_POLICY_FORCE_NONE;
    }
    if (!checkPermission()) {
        return AUDIO_POLICY_FORCE_NONE;
    }
    if (usage < 0 || usage >= AUDIO_POLICY_FORCE_USE_CNT) {
        return AUDIO_POLICY_FORCE_NONE;
    }
@@ -434,9 +428,6 @@ status_t AudioPolicyService::getStreamVolumeIndex(audio_stream_type_t stream, in
    if (mpAudioPolicy == NULL) {
        return NO_INIT;
    }
    if (!checkPermission()) {
        return PERMISSION_DENIED;
    }
    if (stream < 0 || stream >= AUDIO_STREAM_CNT) {
        return BAD_VALUE;
    }