summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAjay Panicker <apanicke@google.com>2018-06-12 14:30:10 -0700
committerAjay Panicker <apanicke@google.com>2018-06-14 14:39:49 -0700
commit2d41d72edb0da52f08e09c5433afc1e0c753b15b (patch)
tree350286d7b3e08317a585a56e1828ff57634bcbce /src
parent5851f9b5afe30aea8625e56fc2192befb63c663b (diff)
downloadandroid_packages_apps_Bluetooth-2d41d72edb0da52f08e09c5433afc1e0c753b15b.tar.gz
android_packages_apps_Bluetooth-2d41d72edb0da52f08e09c5433afc1e0c753b15b.tar.bz2
android_packages_apps_Bluetooth-2d41d72edb0da52f08e09c5433afc1e0c753b15b.zip
Use 1/2 Device max volume when pairing with a new remote device
Instead of using the current system volume which will most often be the speaker volume when connecting to a device we don't have a remembered volume for, use 1/2 the device max volume instead. Bug: 109995379 Test: Pair new device and see volume was 1/2 max Change-Id: Ib3a3963a17faf2fab1b03d47f471780446d2269d (cherry picked from commit ef333ac2bbefb729668cb577b3984924f1031aa2)
Diffstat (limited to 'src')
-rw-r--r--src/com/android/bluetooth/newavrcp/AvrcpVolumeManager.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/com/android/bluetooth/newavrcp/AvrcpVolumeManager.java b/src/com/android/bluetooth/newavrcp/AvrcpVolumeManager.java
index 4b87fac63..fde494740 100644
--- a/src/com/android/bluetooth/newavrcp/AvrcpVolumeManager.java
+++ b/src/com/android/bluetooth/newavrcp/AvrcpVolumeManager.java
@@ -36,11 +36,12 @@ class AvrcpVolumeManager extends AudioDeviceCallback {
public static final boolean DEBUG = true;
// All volumes are stored at system volume values, not AVRCP values
- public static final String VOLUME_MAP = "bluetooth_volume_map";
- public static final String VOLUME_BLACKLIST = "absolute_volume_blacklist";
- public static final int AVRCP_MAX_VOL = 127;
- public static int sDeviceMaxVolume = 0;
- public static final int STREAM_MUSIC = AudioManager.STREAM_MUSIC;
+ private static final String VOLUME_MAP = "bluetooth_volume_map";
+ private static final String VOLUME_BLACKLIST = "absolute_volume_blacklist";
+ private static final int AVRCP_MAX_VOL = 127;
+ private static final int STREAM_MUSIC = AudioManager.STREAM_MUSIC;
+ private static int sDeviceMaxVolume = 0;
+ private static int sNewDeviceVolume = 0;
Context mContext;
AudioManager mAudioManager;
@@ -72,10 +73,9 @@ class AvrcpVolumeManager extends AudioDeviceCallback {
mAudioManager.avrcpSupportsAbsoluteVolume(device.getAddress(), mDeviceMap.get(device));
// Get the current system volume and try to get the preference volume
- int currVolume = mAudioManager.getStreamVolume(STREAM_MUSIC);
- int savedVolume = getVolume(device, currVolume);
+ int savedVolume = getVolume(device, sNewDeviceVolume);
- d("switchVolumeDevice: currVolume=" + currVolume + " savedVolume=" + savedVolume);
+ d("switchVolumeDevice: savedVolume=" + savedVolume);
// If absolute volume for the device is supported, set the volume for the device
if (mDeviceMap.get(device)) {
@@ -91,6 +91,7 @@ class AvrcpVolumeManager extends AudioDeviceCallback {
mAudioManager = audioManager;
mNativeInterface = nativeInterface;
sDeviceMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
+ sNewDeviceVolume = sDeviceMaxVolume / 2;
mAudioManager.registerAudioDeviceCallback(this, null);