Loading services/core/java/com/android/server/audio/AudioService.java +23 −3 Original line number Diff line number Diff line Loading @@ -461,6 +461,8 @@ public class AudioService extends IAudioService.Stub // Forced device usage for communications private int mForcedUseForComm; private int mForcedUseForCommExt; // External state returned by getters: always consistent // with requests by setters // List of binder death handlers for setMode() client processes. // The last process to have called setMode() is at the top of the list. Loading Loading @@ -2890,13 +2892,14 @@ public class AudioService extends IAudioService.Stub mForcedUseForComm = AudioSystem.FORCE_NONE; } mForcedUseForCommExt = mForcedUseForComm; sendMsg(mAudioHandler, MSG_SET_FORCE_USE, SENDMSG_QUEUE, AudioSystem.FOR_COMMUNICATION, mForcedUseForComm, eventSource, 0); } /** @see AudioManager#isSpeakerphoneOn() */ public boolean isSpeakerphoneOn() { return (mForcedUseForComm == AudioSystem.FORCE_SPEAKER); return (mForcedUseForCommExt == AudioSystem.FORCE_SPEAKER); } /** @see AudioManager#setBluetoothScoOn(boolean) */ Loading @@ -2904,6 +2907,13 @@ public class AudioService extends IAudioService.Stub if (!checkAudioSettingsPermission("setBluetoothScoOn()")) { return; } // Only enable calls from system components if (Binder.getCallingUid() >= FIRST_APPLICATION_UID) { mForcedUseForCommExt = on ? AudioSystem.FORCE_BT_SCO : AudioSystem.FORCE_NONE; return; } // for logging only final String eventSource = new StringBuilder("setBluetoothScoOn(").append(on) .append(") from u/pid:").append(Binder.getCallingUid()).append("/") Loading @@ -2913,11 +2923,21 @@ public class AudioService extends IAudioService.Stub public void setBluetoothScoOnInt(boolean on, String eventSource) { if (on) { // do not accept SCO ON if SCO audio is not connected synchronized(mScoClients) { if ((mBluetoothHeadset != null) && (mBluetoothHeadset.getAudioState(mBluetoothHeadsetDevice) != BluetoothHeadset.STATE_AUDIO_CONNECTED)) { mForcedUseForCommExt = AudioSystem.FORCE_BT_SCO; return; } } mForcedUseForComm = AudioSystem.FORCE_BT_SCO; } else if (mForcedUseForComm == AudioSystem.FORCE_BT_SCO) { mForcedUseForComm = AudioSystem.FORCE_NONE; } mForcedUseForCommExt = mForcedUseForComm; AudioSystem.setParameters("BT_SCO="+ (on ? "on" : "off")); sendMsg(mAudioHandler, MSG_SET_FORCE_USE, SENDMSG_QUEUE, AudioSystem.FOR_COMMUNICATION, mForcedUseForComm, eventSource, 0); sendMsg(mAudioHandler, MSG_SET_FORCE_USE, SENDMSG_QUEUE, Loading @@ -2926,7 +2946,7 @@ public class AudioService extends IAudioService.Stub /** @see AudioManager#isBluetoothScoOn() */ public boolean isBluetoothScoOn() { return (mForcedUseForComm == AudioSystem.FORCE_BT_SCO); return (mForcedUseForCommExt == AudioSystem.FORCE_BT_SCO); } /** @see AudioManager#setBluetoothA2dpOn(boolean) */ Loading Loading
services/core/java/com/android/server/audio/AudioService.java +23 −3 Original line number Diff line number Diff line Loading @@ -461,6 +461,8 @@ public class AudioService extends IAudioService.Stub // Forced device usage for communications private int mForcedUseForComm; private int mForcedUseForCommExt; // External state returned by getters: always consistent // with requests by setters // List of binder death handlers for setMode() client processes. // The last process to have called setMode() is at the top of the list. Loading Loading @@ -2890,13 +2892,14 @@ public class AudioService extends IAudioService.Stub mForcedUseForComm = AudioSystem.FORCE_NONE; } mForcedUseForCommExt = mForcedUseForComm; sendMsg(mAudioHandler, MSG_SET_FORCE_USE, SENDMSG_QUEUE, AudioSystem.FOR_COMMUNICATION, mForcedUseForComm, eventSource, 0); } /** @see AudioManager#isSpeakerphoneOn() */ public boolean isSpeakerphoneOn() { return (mForcedUseForComm == AudioSystem.FORCE_SPEAKER); return (mForcedUseForCommExt == AudioSystem.FORCE_SPEAKER); } /** @see AudioManager#setBluetoothScoOn(boolean) */ Loading @@ -2904,6 +2907,13 @@ public class AudioService extends IAudioService.Stub if (!checkAudioSettingsPermission("setBluetoothScoOn()")) { return; } // Only enable calls from system components if (Binder.getCallingUid() >= FIRST_APPLICATION_UID) { mForcedUseForCommExt = on ? AudioSystem.FORCE_BT_SCO : AudioSystem.FORCE_NONE; return; } // for logging only final String eventSource = new StringBuilder("setBluetoothScoOn(").append(on) .append(") from u/pid:").append(Binder.getCallingUid()).append("/") Loading @@ -2913,11 +2923,21 @@ public class AudioService extends IAudioService.Stub public void setBluetoothScoOnInt(boolean on, String eventSource) { if (on) { // do not accept SCO ON if SCO audio is not connected synchronized(mScoClients) { if ((mBluetoothHeadset != null) && (mBluetoothHeadset.getAudioState(mBluetoothHeadsetDevice) != BluetoothHeadset.STATE_AUDIO_CONNECTED)) { mForcedUseForCommExt = AudioSystem.FORCE_BT_SCO; return; } } mForcedUseForComm = AudioSystem.FORCE_BT_SCO; } else if (mForcedUseForComm == AudioSystem.FORCE_BT_SCO) { mForcedUseForComm = AudioSystem.FORCE_NONE; } mForcedUseForCommExt = mForcedUseForComm; AudioSystem.setParameters("BT_SCO="+ (on ? "on" : "off")); sendMsg(mAudioHandler, MSG_SET_FORCE_USE, SENDMSG_QUEUE, AudioSystem.FOR_COMMUNICATION, mForcedUseForComm, eventSource, 0); sendMsg(mAudioHandler, MSG_SET_FORCE_USE, SENDMSG_QUEUE, Loading @@ -2926,7 +2946,7 @@ public class AudioService extends IAudioService.Stub /** @see AudioManager#isBluetoothScoOn() */ public boolean isBluetoothScoOn() { return (mForcedUseForComm == AudioSystem.FORCE_BT_SCO); return (mForcedUseForCommExt == AudioSystem.FORCE_BT_SCO); } /** @see AudioManager#setBluetoothA2dpOn(boolean) */ Loading