fix AudioManager.testVolume()

Do not use master volume map to calculate volume delta
if platform does not use master volume.

Bug: 18702149.
Change-Id: Iad83b6942c3516dfe22c33da9228b7b1720b2827
diff --git a/tests/tests/media/src/android/media/cts/AudioManagerTest.java b/tests/tests/media/src/android/media/cts/AudioManagerTest.java
index 255baed..f58e6ab 100644
--- a/tests/tests/media/src/android/media/cts/AudioManagerTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioManagerTest.java
@@ -57,6 +57,7 @@
     private final static long TIME_TO_PLAY = 2000;
     private AudioManager mAudioManager;
     private boolean mHasVibrator;
+    private boolean mUseMasterVolume;
     private boolean mUseFixedVolume;
     private int[] mMasterVolumeRamp;
     private TreeMap<Integer, Integer> mMasterVolumeMap = new TreeMap<Integer, Integer>();
@@ -68,6 +69,8 @@
         mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
         Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
         mHasVibrator = (vibrator != null) && vibrator.hasVibrator();
+        mUseMasterVolume = mContext.getResources().getBoolean(
+                Resources.getSystem().getIdentifier("config_useMasterVolume", "bool", "android"));
         mUseFixedVolume = mContext.getResources().getBoolean(
                 Resources.getSystem().getIdentifier("config_useFixedVolume", "bool", "android"));
         mMasterVolumeRamp = mContext.getResources().getIntArray(
@@ -464,6 +467,9 @@
     }
 
     private int getVolumeDelta(int volume) {
+        if (!mUseMasterVolume) {
+            return 1;
+        }
         int volumeDelta = mMasterVolumeMap.floorEntry(volume).getValue();
         assertTrue(volumeDelta > 0);
         return volumeDelta;