Merge "AudioService: Don't honour SCO ON request if SCO is not connected" into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
44eac965d5
@@ -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.
|
||||
@@ -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) */
|
||||
@@ -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("/")
|
||||
@@ -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,
|
||||
@@ -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) */
|
||||
|
||||
Reference in New Issue
Block a user