private static final String TAG = "HeadsetStateMachine";
private static final boolean DBG = true;
+ private static final String HEADSET_NAME = "bt_headset_name";
+ private static final String HEADSET_NREC = "bt_headset_nrec";
+
static final int CONNECT = 1;
static final int DISCONNECT = 2;
static final int CONNECT_AUDIO = 3;
mCurrentDevice = device;
transitionTo(mConnected);
}
+ configAudioParameters();
break;
case HeadsetHalConstants.CONNECTION_STATE_DISCONNECTING:
Log.w(TAG, "Ignore HF DISCONNECTING event, device: " + device);
transitionTo(mConnected);
}
}
+ configAudioParameters();
break;
case HeadsetHalConstants.CONNECTION_STATE_CONNECTING:
if ((mCurrentDevice != null) && mCurrentDevice.equals(device)) {
case EVENT_TYPE_SEND_DTMF:
processSendDtmf(event.valueInt);
break;
+ case EVENT_TYPE_NOICE_REDUCTION:
+ processNoiceReductionEvent(event.valueInt);
+ break;
case EVENT_TYPE_AT_CHLD:
processAtChld(event.valueInt);
break;
}
private class AudioOn extends State {
- // Audio parameters
- private static final String HEADSET_NAME = "bt_headset_name";
- private static final String HEADSET_NREC = "bt_headset_nrec";
@Override
public void enter() {
log("Enter AudioOn: " + getCurrentMessage().what);
- mAudioManager.setParameters(HEADSET_NAME + "=" + getCurrentDeviceName() + ";" +
- HEADSET_NREC + "=on");
}
@Override
}
}
- // enable 1 enable noice reduction
- // 0 disable noice reduction
- private void processNoiceReductionEvent(int enable) {
- if (enable == 1) {
- mAudioManager.setParameters(HEADSET_NREC + "=on");
- } else {
- mAudioManager.setParameters(HEADSET_NREC + "off");
- }
- }
-
private void processIntentScoVolume(Intent intent) {
int volumeValue = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, 0);
if (mPhoneState.getSpeakerVolume() != volumeValue) {
if (DBG) log("Audio state " + device + ": " + prevState + "->" + newState);
}
+ private void configAudioParameters()
+ {
+ // Reset NREC on connect event. Headset will override later
+ mAudioManager.setParameters(HEADSET_NAME + "=" + getCurrentDeviceName() + ";" +
+ HEADSET_NREC + "=on");
+ }
+
private void processAnswerCall() {
if (mPhoneProxy != null) {
try {
}
}
+ // enable 1 enable noice reduction
+ // 0 disable noice reduction
+ private void processNoiceReductionEvent(int enable) {
+ if (enable == 1) {
+ mAudioManager.setParameters(HEADSET_NREC + "=on");
+ } else {
+ mAudioManager.setParameters(HEADSET_NREC + "off");
+ }
+ }
+
private void processAtChld(int chld) {
if (mPhoneProxy != null) {
try {