Merge de3bead339a8241185e1afadc8ac0ce6ee5b69e9 on remote branch
Change-Id: Ie90c217e5cc357c2a100065f2cb84d64e0fd6492
diff --git a/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java b/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java
index 3681bc6..c415690 100644
--- a/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java
+++ b/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java
@@ -1153,7 +1153,7 @@
byte[] bdaddr = data.getByteArray("BdAddress");
String address = Utils.getAddressStringFromByte(bdaddr);
BluetoothDevice device, activeDevice = null;
- Log.v(TAG, "event for device address " + address);
+ Log.v(TAG, "event for device address " + address );
deviceIndex = getIndexForDevice(mAdapter.getRemoteDevice(address));
if (deviceIndex == INVALID_DEVICE_INDEX) {
Log.e(TAG,"invalid index for device");
@@ -1200,6 +1200,8 @@
sendMessageDelayed(obtainMessage(MSG_ABS_VOL_TIMEOUT,
0, 0, deviceFeatures[deviceIndex].mCurrentDevice),
CMD_TIMEOUT_DELAY);
+ deviceFeatures[deviceIndex].mLastLocalVolume = convertToAudioStreamVolume
+ (deviceFeatures[deviceIndex].mLastRequestedVolume);
deviceFeatures[deviceIndex].mLastRequestedVolume = -1;
deviceFeatures[deviceIndex].mLocalVolume = convertToAudioStreamVolume(absVol);
Log.v(TAG, "Reset cached lastreq vol = " +
@@ -1313,6 +1315,15 @@
deviceFeatures[deviceIndex].mLocalVolume = volIndex;
deviceFeatures[deviceIndex].mLastRequestedVolume = -1;
+ /*Audio volume update to MM audio if message type is accept and setAbsoluteVolume
+ and accept response volume matched*/
+ if ((msg.arg2 != AVRC_RSP_ACCEPT) || (msg.arg2 == AVRC_RSP_ACCEPT &&
+ deviceFeatures[deviceIndex].mLastLocalVolume != -1 &&
+ deviceFeatures[deviceIndex].mLastLocalVolume != volIndex)) {
+ notifyVolumeChanged(deviceFeatures[deviceIndex].mLocalVolume, isShowUI);
+ long pecentVolChanged = ((long)absVol * 100) / 0x7f;
+ Log.e(TAG, "percent volume changed: " + pecentVolChanged + "%");
+ }
if (deviceFeatures[deviceIndex].mLastLocalVolume != -1
&& msg.arg2 == AVRC_RSP_ACCEPT) {
if (deviceFeatures[deviceIndex].mLastLocalVolume != volIndex) {
@@ -1325,10 +1336,7 @@
deviceFeatures[deviceIndex].mLocalVolume;
}
}
- notifyVolumeChanged(deviceFeatures[deviceIndex].mLocalVolume, isShowUI);
deviceFeatures[deviceIndex].mRemoteVolume = absVol;
- long pecentVolChanged = ((long)absVol * 100) / 0x7f;
- Log.e(TAG, "percent volume changed: " + pecentVolChanged + "%");
} else if (deviceFeatures[deviceIndex].mLastRemoteVolume > 0
&& deviceFeatures[deviceIndex].mLastRemoteVolume < AVRCP_MAX_VOL &&
deviceFeatures[deviceIndex].mLocalVolume == volIndex &&
@@ -1356,7 +1364,7 @@
case MSG_SET_ABSOLUTE_VOLUME:
{
- if (DEBUG) Log.v(TAG, "MSG_SET_ABSOLUTE_VOLUME");
+ if (DEBUG) Log.v(TAG, "MSG_SET_ABSOLUTE_VOLUME" + msg.arg1);
int avrcpVolume = convertToAvrcpVolume(msg.arg1);
BluetoothDevice activeDevice = mA2dpService.getActiveDevice();
@@ -1365,7 +1373,10 @@
if (deviceFeatures[i].mCurrentDevice != null && activeDevice != null &&
(isTwsPlusPair(activeDevice, deviceFeatures[i].mCurrentDevice) ||
Objects.equals(activeDevice, deviceFeatures[i].mCurrentDevice)) &&
- deviceFeatures[i].isAbsoluteVolumeSupportingDevice) {
+ deviceFeatures[i].isAbsoluteVolumeSupportingDevice &&
+ ((deviceFeatures[i].mVolCmdSetInProgress ||
+ deviceFeatures[i].mVolCmdAdjustInProgress) ||
+ deviceFeatures[i].mLocalVolume != msg.arg1)) {
deviceIndex = i;
@@ -2948,9 +2959,10 @@
}
public void setAbsoluteVolume(int volume) {
- Log.v(TAG, "Enter setAbsoluteVolume");
+ int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
+ Log.v(TAG, "Enter setAbsoluteVolume" + streamVolume);
if (volume == mLocalVolume) {
- if (DEBUG) Log.v(TAG, "setAbsoluteVolume is setting same index, ignore " + volume);
+ if (DEBUG) Log.v(TAG, "setAbsoluteVolume is setting same index, ignore " + volume + " stream volume ");
return;
}
Log.d(TAG, "pts_test = " + pts_test + " volume = " + volume +