diff options
author | Bryce Lee <brycelee@google.com> | 2015-11-17 16:14:24 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-11-17 16:14:24 +0000 |
commit | e58438d821210e57c2240befdaa99e4ab996c51c (patch) | |
tree | 39980577d90abbb03d37742c93de78397089fc1c | |
parent | c3da0f7bb39fc5d234a360bc6a1dd6c1d8382ee2 (diff) | |
parent | 9e1b34b2a5a80c9b16cfc9e71fd4ff015086ab16 (diff) | |
download | android_packages_apps_Bluetooth-e58438d821210e57c2240befdaa99e4ab996c51c.tar.gz android_packages_apps_Bluetooth-e58438d821210e57c2240befdaa99e4ab996c51c.tar.bz2 android_packages_apps_Bluetooth-e58438d821210e57c2240befdaa99e4ab996c51c.zip |
Allow for automatic routing on HF AG to be disabled.
am: 9e1b34b2a5
* commit '9e1b34b2a5a80c9b16cfc9e71fd4ff015086ab16':
Allow for automatic routing on HF AG to be disabled.
-rwxr-xr-x | src/com/android/bluetooth/hfp/HeadsetService.java | 23 | ||||
-rw-r--r-- | src/com/android/bluetooth/hfp/HeadsetStateMachine.java | 13 |
2 files changed, 35 insertions, 1 deletions
diff --git a/src/com/android/bluetooth/hfp/HeadsetService.java b/src/com/android/bluetooth/hfp/HeadsetService.java index f6153cb42..cda51fce1 100755 --- a/src/com/android/bluetooth/hfp/HeadsetService.java +++ b/src/com/android/bluetooth/hfp/HeadsetService.java @@ -243,6 +243,21 @@ public class HeadsetService extends ProfileService { return service.disconnectAudio(); } + public void setAudioRouteAllowed(boolean allowed) { + HeadsetService service = getService(); + if (service == null) return; + service.setAudioRouteAllowed(allowed); + } + + public boolean getAudioRouteAllowed() { + HeadsetService service = getService(); + if (service != null) { + return service.getAudioRouteAllowed(); + } + + return false; + } + public boolean startScoUsingVirtualVoiceCall(BluetoothDevice device) { HeadsetService service = getService(); if (service == null) return false; @@ -448,6 +463,14 @@ public class HeadsetService extends ProfileService { return mStateMachine.getAudioState(device); } + public void setAudioRouteAllowed(boolean allowed) { + mStateMachine.setAudioRouteAllowed(allowed); + } + + public boolean getAudioRouteAllowed() { + return mStateMachine.getAudioRouteAllowed(); + } + boolean connectAudio() { // TODO(BT) BLUETOOTH or BLUETOOTH_ADMIN permission enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java index 0cf5f335f..fc55bae77 100644 --- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java @@ -162,6 +162,9 @@ final class HeadsetStateMachine extends StateMachine { private IBluetoothHeadsetPhone mPhoneProxy; private boolean mNativeAvailable; + // Indicates whether audio can be routed to the device. + private boolean mAudioRouteAllowed = true; + // mCurrentDevice is the device connected before the state changes // mTargetDevice is the device to be connected // mIncomingDevice is the device connecting to us, valid only in Pending state @@ -2153,6 +2156,14 @@ final class HeadsetStateMachine extends StateMachine { return false; } + public void setAudioRouteAllowed(boolean allowed) { + mAudioRouteAllowed = allowed; + } + + public boolean getAudioRouteAllowed() { + return mAudioRouteAllowed; + } + int getAudioState(BluetoothDevice device) { synchronized(this) { if (mConnectedDevicesList.size() == 0) { @@ -3292,7 +3303,7 @@ final class HeadsetStateMachine extends StateMachine { // Accept incoming SCO only when there is active call, VR activated, // active VOIP call private boolean isScoAcceptable() { - return (mVoiceRecognitionStarted || isInCall()); + return mAudioRouteAllowed && (mVoiceRecognitionStarted || isInCall()); } boolean isConnected() { |