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)
diff --git a/src/com/android/bluetooth/newavrcp/AvrcpVolumeManager.java b/src/com/android/bluetooth/newavrcp/AvrcpVolumeManager.java
index 4b87fac..fde4947 100644
--- a/src/com/android/bluetooth/newavrcp/AvrcpVolumeManager.java
+++ b/src/com/android/bluetooth/newavrcp/AvrcpVolumeManager.java
@@ -36,11 +36,12 @@
     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 @@
         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 @@
         mAudioManager = audioManager;
         mNativeInterface = nativeInterface;
         sDeviceMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
+        sNewDeviceVolume = sDeviceMaxVolume / 2;
 
         mAudioManager.registerAudioDeviceCallback(this, null);