summaryrefslogtreecommitdiffstats
path: root/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/bluetooth/hfp/HeadsetStateMachine.java')
-rw-r--r--src/com/android/bluetooth/hfp/HeadsetStateMachine.java51
1 files changed, 38 insertions, 13 deletions
diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
index 276948152..f3bcea996 100644
--- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
+++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
@@ -2407,10 +2407,16 @@ final class HeadsetStateMachine extends StateMachine {
}
public boolean isBluetoothVoiceDialingEnabled( BluetoothDevice device) {
- int RemoteBrsf = mHeadsetBrsf.get(device);
- Log.d(TAG, "isBluetoothVoiceDialingEnabled mRemoteBrsf: " + RemoteBrsf +
- "supported: " + (RemoteBrsf & BRSF_HF_VOICE_REG_ACT));
- return ((RemoteBrsf & BRSF_HF_VOICE_REG_ACT) != 0x0) ? true : false;
+ int remoteBrsf = 0;
+ if (mHeadsetBrsf != null && !mHeadsetBrsf.isEmpty()) {
+ remoteBrsf = mHeadsetBrsf.get(device);
+ } else {
+ Log.e(TAG,"remote device supported features not found");
+ return false;
+ }
+ Log.d(TAG, "isBluetoothVoiceDialingEnabled mRemoteBrsf: " + remoteBrsf +
+ "supported: " + (remoteBrsf & BRSF_HF_VOICE_REG_ACT));
+ return ((remoteBrsf & BRSF_HF_VOICE_REG_ACT) != 0x0) ? true : false;
}
int getAudioState(BluetoothDevice device) {
@@ -2512,7 +2518,11 @@ final class HeadsetStateMachine extends StateMachine {
// Whereas for VoiceDial we want to activate the SCO connection but we are still
// in MODE_NORMAL and hence the need to explicitly suspend the A2DP stream
mAudioManager.setParameters("A2dpSuspended=true");
- connectAudioNative(getByteAddress(device));
+ if (device != null) {
+ connectAudioNative(getByteAddress(device));
+ } else {
+ Log.e(TAG, "device not found for VR");
+ }
}
if (mStartVoiceRecognitionWakeLock.isHeld()) {
@@ -2680,9 +2690,15 @@ final class HeadsetStateMachine extends StateMachine {
{
// 1. update nrec value
// 2. update headset name
+ int mCodec = 0;
+ int mNrec = 0;
HashMap<String, Integer> AudioParam = mHeadsetAudioParam.get(device);
- int mCodec = AudioParam.get("codec");
- int mNrec = AudioParam.get("NREC");
+ if (AudioParam != null && !AudioParam.isEmpty()) {
+ mCodec = AudioParam.get("codec");
+ mNrec = AudioParam.get("NREC");
+ } else {
+ Log.e(TAG,"setAudioParameters: AudioParam not found");
+ }
if (mCodec != WBS_CODEC) {
Log.d(TAG, "Use NBS PCM samples:" + device);
mAudioManager.setParameters(HEADSET_WBS + "=off");
@@ -3104,18 +3120,27 @@ final class HeadsetStateMachine extends StateMachine {
// 0 disable noice reduction
private void processNoiceReductionEvent(int enable, BluetoothDevice device) {
HashMap<String, Integer> AudioParamNrec = mHeadsetAudioParam.get(device);
- if (enable == 1)
- AudioParamNrec.put("NREC", 1);
- else
- AudioParamNrec.put("NREC", 0);
- log("NREC value for device :" + device + " is: " + AudioParamNrec.get("NREC"));
+ if (AudioParamNrec != null && !AudioParamNrec.isEmpty()) {
+ if (enable == 1)
+ AudioParamNrec.put("NREC", 1);
+ else
+ AudioParamNrec.put("NREC", 0);
+ log("NREC value for device :" + device + " is: " +
+ AudioParamNrec.get("NREC"));
+ } else {
+ Log.e(TAG,"processNoiceReductionEvent: AudioParamNrec is null ");
+ }
}
// 2 - WBS on
// 1 - NBS on
private void processWBSEvent(int enable, BluetoothDevice device) {
HashMap<String, Integer> AudioParamCodec = mHeadsetAudioParam.get(device);
- AudioParamCodec.put("codec", enable);
+ if (AudioParamCodec != null && !AudioParamCodec.isEmpty()) {
+ AudioParamCodec.put("codec", enable);
+ } else {
+ Log.e(TAG,"processWBSEvent: AudioParamNrec is null ");
+ }
if (enable == 2) {
Log.d(TAG, "AudioManager.setParameters bt_wbs=on for " +
device.getName() + " - " + device.getAddress());