commit | 4b923c4ba4d06d18493d85f05bd17004988afdd9 | [log] [tgz] |
---|---|---|
author | Vasu Nori <vnori@norinori.mtv.corp.google.com> | Wed Sep 13 12:38:47 2017 -0700 |
committer | Vasu Nori <vnori@google.com> | Wed Sep 13 13:37:59 2017 -0700 |
tree | 543a3f5e5b7eb60946ddc1d147cbdba603e29b15 | |
parent | 0bda2f3f7ee353c1e0a1bb6b11735608f7902091 [diff] |
consider the situations where the device has only one volume level set. Bug: 65125561 Test: runtest bluetooth -c com.android.bluetooth.hfpclient.HeadsetClientStateMachineTest doesn't crash now Change-Id: I3474e60f04732c60de215a41125a9436c5ff122c
diff --git a/android/app/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java b/android/app/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java index 180d91c..604ab5a 100755 --- a/android/app/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java +++ b/android/app/src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java
@@ -751,7 +751,7 @@ } static int amToHfVol(int amVol) { - int amRange = mMaxAmVcVol - mMinAmVcVol; + int amRange = (mMaxAmVcVol > mMinAmVcVol) ? (mMaxAmVcVol - mMinAmVcVol) : 1; int hfRange = MAX_HFP_SCO_VOICE_CALL_VOLUME - MIN_HFP_SCO_VOICE_CALL_VOLUME; int hfOffset = (hfRange * (amVol - mMinAmVcVol)) / amRange; int hfVol = MIN_HFP_SCO_VOICE_CALL_VOLUME + hfOffset;