OSDN Git Service

Persist volume level on reconnections for Hearing Aid
authorJakub Pawlowski <jpawlowski@google.com>
Wed, 4 Apr 2018 17:15:12 +0000 (10:15 -0700)
committerJakub Pawlowski <jpawlowski@google.com>
Thu, 5 Apr 2018 04:58:45 +0000 (04:58 +0000)
Devices in mFullVolumeDevices have volume level reset to maximum value
in checkFixedVolumeDevices.

Bug: 69623109
Test: change Hearing Aid volume, restart phone, verify volume persisted
Change-Id: Iba134c0b3dc959c19c59f89c3d4ac02eed1e216f

services/core/java/com/android/server/audio/AudioService.java

index 3e82c25..8212463 100644 (file)
@@ -588,7 +588,7 @@ public class AudioService extends IAudioService.Stub
             AudioSystem.DEVICE_OUT_HDMI_ARC |
             AudioSystem.DEVICE_OUT_SPDIF |
             AudioSystem.DEVICE_OUT_AUX_LINE;
-    int mFullVolumeDevices = AudioSystem.DEVICE_OUT_HEARING_AID;
+    int mFullVolumeDevices = 0;
 
     private final boolean mMonitorRotation;
 
@@ -4765,6 +4765,8 @@ public class AudioService extends IAudioService.Stub
                 index = getAbsoluteVolumeIndex((getIndex(device) + 5)/10);
             } else if ((device & mFullVolumeDevices) != 0) {
                 index = (mIndexMax + 5)/10;
+            } else if ((device & AudioSystem.DEVICE_OUT_HEARING_AID) != 0) {
+                index = (mIndexMax + 5)/10;
             } else {
                 index = (getIndex(device) + 5)/10;
             }
@@ -4785,6 +4787,8 @@ public class AudioService extends IAudioService.Stub
                             index = getAbsoluteVolumeIndex((getIndex(device) + 5)/10);
                         } else if ((device & mFullVolumeDevices) != 0) {
                             index = (mIndexMax + 5)/10;
+                        } else if ((device & AudioSystem.DEVICE_OUT_HEARING_AID) != 0) {
+                            index = (mIndexMax + 5)/10;
                         } else {
                             index = (mIndexMap.valueAt(i) + 5)/10;
                         }