Audio: Remove the concept of master volume.

- Remove two config resources (use master volume, and volume ramp).
- Remove master volume adjustments / getters / intents.
- Retain @hidden setMasterMute, needed for device admin
- Remove master volume logic in AudioService.
- Remove master volume logic in VolumePanel.
- Rename "getMasterStreamType" to "getUiSoundsStreamType" to avoid confusion.

Bug: 19582978
Change-Id: Id02c8fa4898cff3b913147f5ac1b4038e2e7cc24
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 018d77a..4b7f698 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -188,7 +188,6 @@
     // AudioHandler messages
     private static final int MSG_SET_DEVICE_VOLUME = 0;
     private static final int MSG_PERSIST_VOLUME = 1;
-    private static final int MSG_PERSIST_MASTER_VOLUME = 2;
     private static final int MSG_PERSIST_RINGER_MODE = 3;
     private static final int MSG_MEDIA_SERVER_DIED = 4;
     private static final int MSG_PLAY_SOUND_EFFECT = 5;
@@ -239,10 +238,6 @@
     private final Object mSoundEffectsLock = new Object();
     private static final int NUM_SOUNDPOOL_CHANNELS = 4;
 
-    // Internally master volume is a float in the 0.0 - 1.0 range,
-    // but to support integer based AudioManager API we translate it to 0 - 100
-    private static final int MAX_MASTER_VOLUME = 100;
-
     // Maximum volume adjust steps allowed in a single batch call.
     private static final int MAX_BATCH_VOLUME_ADJUST_STEPS = 4;
 
@@ -386,11 +381,6 @@
     // Forced device usage for communications
     private int mForcedUseForComm;
 
-    // True if we have master volume support
-    private final boolean mUseMasterVolume;
-
-    private final int[] mMasterVolumeRamp;
-
     // List of binder death handlers for setMode() client processes.
     // The last process to have called setMode() is at the top of the list.
     private final ArrayList <SetModeDeathHandler> mSetModeDeathHandlers = new ArrayList <SetModeDeathHandler>();
@@ -595,10 +585,6 @@
 
         mUseFixedVolume = mContext.getResources().getBoolean(
                 com.android.internal.R.bool.config_useFixedVolume);
-        mUseMasterVolume = context.getResources().getBoolean(
-                com.android.internal.R.bool.config_useMasterVolume);
-        mMasterVolumeRamp = context.getResources().getIntArray(
-                com.android.internal.R.array.config_masterVolumeRamp);
 
         // must be called before readPersistedSettings() which needs a valid mStreamVolumeAlias[]
         // array initialized by updateStreamVolumeAlias()
@@ -647,8 +633,6 @@
 
         context.registerReceiver(mReceiver, intentFilter);
 
-        restoreMasterVolume();
-
         LocalServices.addService(AudioManagerInternal.class, new AudioServiceInternal());
     }
 
@@ -882,7 +866,7 @@
                 UserHandle.USER_CURRENT);
 
         boolean masterMute = System.getIntForUser(cr, System.VOLUME_MASTER_MUTE,
-                                                  0, UserHandle.USER_CURRENT) == 1;
+                0, UserHandle.USER_CURRENT) == 1;
         if (mUseFixedVolume) {
             masterMute = false;
             AudioSystem.setMasterVolume(1.0f);
@@ -1050,7 +1034,7 @@
         // If either the client forces allowing ringer modes for this adjustment,
         // or the stream type is one that is affected by ringer modes
         if (((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) ||
-                (streamTypeAlias == getMasterStreamType())) {
+                (streamTypeAlias == getUiSoundsStreamType())) {
             int ringerMode = getRingerModeInternal();
             // do not vibrate if already in vibrate mode
             if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
@@ -1183,33 +1167,6 @@
         }
     }
 
-    /** @see AudioManager#adjustMasterVolume(int, int) */
-    public void adjustMasterVolume(int steps, int flags, String callingPackage) {
-        adjustMasterVolume(steps, flags, callingPackage, Binder.getCallingUid());
-    }
-
-    public void adjustMasterVolume(int steps, int flags, String callingPackage, int uid) {
-        if (mUseFixedVolume) {
-            return;
-        }
-        if (isMuteAdjust(steps)) {
-            setMasterMuteInternal(steps, flags, callingPackage, uid);
-            return;
-        }
-        ensureValidSteps(steps);
-        int volume = Math.round(AudioSystem.getMasterVolume() * MAX_MASTER_VOLUME);
-        int delta = 0;
-        int numSteps = Math.abs(steps);
-        int direction = steps > 0 ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER;
-        for (int i = 0; i < numSteps; ++i) {
-            delta = findVolumeDelta(direction, volume);
-            volume += delta;
-        }
-
-        //Log.d(TAG, "adjustMasterVolume volume: " + volume + " steps: " + steps);
-        setMasterVolume(volume, flags, callingPackage, uid);
-    }
-
     // StreamVolumeCommand contains the information needed to defer the process of
     // setStreamVolume() in case the user has to acknowledge the safe volume warning message.
     class StreamVolumeCommand {
@@ -1235,9 +1192,9 @@
 
     private void onSetStreamVolume(int streamType, int index, int flags, int device) {
         setStreamVolumeInt(mStreamVolumeAlias[streamType], index, device, false);
-        // setting volume on master stream type also controls silent mode
+        // setting volume on ui sounds stream type also controls silent mode
         if (((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) ||
-                (mStreamVolumeAlias[streamType] == getMasterStreamType())) {
+                (mStreamVolumeAlias[streamType] == getUiSoundsStreamType())) {
             int newRingerMode;
             if (index == 0) {
                 newRingerMode = mHasVibrator ? AudioManager.RINGER_MODE_VIBRATE
@@ -1381,41 +1338,6 @@
         }
     }
 
-    private int findVolumeDelta(int direction, int volume) {
-        int delta = 0;
-        if (direction == AudioManager.ADJUST_RAISE) {
-            if (volume == MAX_MASTER_VOLUME) {
-                return 0;
-            }
-            // This is the default value if we make it to the end
-            delta = mMasterVolumeRamp[1];
-            // If we're raising the volume move down the ramp array until we
-            // find the volume we're above and use that groups delta.
-            for (int i = mMasterVolumeRamp.length - 1; i > 1; i -= 2) {
-                if (volume >= mMasterVolumeRamp[i - 1]) {
-                    delta = mMasterVolumeRamp[i];
-                    break;
-                }
-            }
-        } else if (direction == AudioManager.ADJUST_LOWER){
-            if (volume == 0) {
-                return 0;
-            }
-            int length = mMasterVolumeRamp.length;
-            // This is the default value if we make it to the end
-            delta = -mMasterVolumeRamp[length - 1];
-            // If we're lowering the volume move up the ramp array until we
-            // find the volume we're below and use the group below it's delta
-            for (int i = 2; i < length; i += 2) {
-                if (volume <= mMasterVolumeRamp[i]) {
-                    delta = -mMasterVolumeRamp[i - 1];
-                    break;
-                }
-            }
-        }
-        return delta;
-    }
-
     private void sendBroadcastToAll(Intent intent) {
         intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
         intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
@@ -1464,16 +1386,6 @@
     }
 
     // UI update and Broadcast Intent
-    private void sendMasterVolumeUpdate(int flags, int oldVolume, int newVolume) {
-        mVolumeController.postMasterVolumeChanged(updateFlagsForSystemAudio(flags));
-
-        Intent intent = new Intent(AudioManager.MASTER_VOLUME_CHANGED_ACTION);
-        intent.putExtra(AudioManager.EXTRA_PREV_MASTER_VOLUME_VALUE, oldVolume);
-        intent.putExtra(AudioManager.EXTRA_MASTER_VOLUME_VALUE, newVolume);
-        sendBroadcastToAll(intent);
-    }
-
-    // UI update and Broadcast Intent
     private void sendMasterMuteUpdate(boolean muted, int flags) {
         mVolumeController.postMasterMuteChanged(updateFlagsForSystemAudio(flags));
         broadcastMasterMuteStatus(muted);
@@ -1641,27 +1553,21 @@
         }
     }
 
-    private void setMasterMuteInternal(int adjust, int flags, String callingPackage, int uid) {
+    private void setMasterMuteInternal(boolean mute, int flags, String callingPackage, int uid) {
         if (mAppOps.noteOp(AppOpsManager.OP_AUDIO_MASTER_VOLUME, uid, callingPackage)
                 != AppOpsManager.MODE_ALLOWED) {
             return;
         }
-        boolean state;
-        if (adjust == AudioManager.ADJUST_TOGGLE_MUTE) {
-            state = !AudioSystem.getMasterMute();
-        } else {
-            state = adjust == AudioManager.ADJUST_MUTE;
-        }
-        if (state != AudioSystem.getMasterMute()) {
-            setSystemAudioMute(state);
-            AudioSystem.setMasterMute(state);
+        if (mute != AudioSystem.getMasterMute()) {
+            setSystemAudioMute(mute);
+            AudioSystem.setMasterMute(mute);
             // Post a persist master volume msg
-            sendMsg(mAudioHandler, MSG_PERSIST_MASTER_VOLUME_MUTE, SENDMSG_REPLACE, state ? 1
+            sendMsg(mAudioHandler, MSG_PERSIST_MASTER_VOLUME_MUTE, SENDMSG_REPLACE, mute ? 1
                     : 0, UserHandle.getCallingUserId(), null, PERSIST_DELAY);
-            sendMasterMuteUpdate(state, flags);
+            sendMasterMuteUpdate(mute, flags);
 
             Intent intent = new Intent(AudioManager.MASTER_MUTE_CHANGED_ACTION);
-            intent.putExtra(AudioManager.EXTRA_MASTER_VOLUME_MUTED, state);
+            intent.putExtra(AudioManager.EXTRA_MASTER_VOLUME_MUTED, mute);
             sendBroadcastToAll(intent);
         }
     }
@@ -1671,6 +1577,10 @@
         return AudioSystem.getMasterMute();
     }
 
+    public void setMasterMute(boolean mute, int flags, String callingPackage) {
+        setMasterMuteInternal(mute, flags, callingPackage, Binder.getCallingUid());
+    }
+
     protected static int getMaxStreamVolume(int streamType) {
         return MAX_STREAM_VOLUME[streamType];
     }
@@ -1694,63 +1604,12 @@
         }
     }
 
-    @Override
-    public int getMasterVolume() {
-        if (isMasterMute()) return 0;
-        return getLastAudibleMasterVolume();
-    }
-
-    @Override
-    public void setMasterVolume(int volume, int flags, String callingPackage) {
-        setMasterVolume(volume, flags, callingPackage, Binder.getCallingUid());
-    }
-
-    public void setMasterVolume(int volume, int flags, String callingPackage, int uid) {
-        if (mUseFixedVolume) {
-            return;
-        }
-
-        if (mAppOps.noteOp(AppOpsManager.OP_AUDIO_MASTER_VOLUME, uid, callingPackage)
-                != AppOpsManager.MODE_ALLOWED) {
-            return;
-        }
-
-        if (volume < 0) {
-            volume = 0;
-        } else if (volume > MAX_MASTER_VOLUME) {
-            volume = MAX_MASTER_VOLUME;
-        }
-        doSetMasterVolume((float)volume / MAX_MASTER_VOLUME, flags);
-    }
-
-    private void doSetMasterVolume(float volume, int flags) {
-        // don't allow changing master volume when muted
-        if (!AudioSystem.getMasterMute()) {
-            int oldVolume = getMasterVolume();
-            AudioSystem.setMasterVolume(volume);
-
-            int newVolume = getMasterVolume();
-            if (newVolume != oldVolume) {
-                // Post a persist master volume msg
-                sendMsg(mAudioHandler, MSG_PERSIST_MASTER_VOLUME, SENDMSG_REPLACE,
-                        Math.round(volume * (float)1000.0), 0, null, PERSIST_DELAY);
-                setSystemAudioVolume(oldVolume, newVolume, getMasterMaxVolume(), flags);
-            }
-            // Send the volume update regardless whether there was a change.
-            sendMasterVolumeUpdate(flags, oldVolume, newVolume);
-        }
-    }
-
     /** @see AudioManager#getStreamMaxVolume(int) */
     public int getStreamMaxVolume(int streamType) {
         ensureValidStreamType(streamType);
         return (mStreamStates[streamType].getMaxIndex() + 5) / 10;
     }
 
-    public int getMasterMaxVolume() {
-        return MAX_MASTER_VOLUME;
-    }
-
     /** Get last audible volume before stream was muted. */
     public int getLastAudibleStreamVolume(int streamType) {
         ensureValidStreamType(streamType);
@@ -1758,13 +1617,8 @@
         return (mStreamStates[streamType].getIndex(device) + 5) / 10;
     }
 
-    /** Get last audible master volume before it was muted. */
-    public int getLastAudibleMasterVolume() {
-        return Math.round(AudioSystem.getMasterVolume() * MAX_MASTER_VOLUME);
-    }
-
-    /** @see AudioManager#getMasterStreamType()  */
-    public int getMasterStreamType() {
+    /** @see AudioManager#getUiSoundsStreamType()  */
+    public int getUiSoundsStreamType() {
         return mStreamVolumeAlias[AudioSystem.STREAM_SYSTEM];
     }
 
@@ -1932,20 +1786,6 @@
         }
     }
 
-    private void restoreMasterVolume() {
-        if (mUseFixedVolume) {
-            AudioSystem.setMasterVolume(1.0f);
-            return;
-        }
-        if (mUseMasterVolume) {
-            float volume = Settings.System.getFloatForUser(mContentResolver,
-                    Settings.System.VOLUME_MASTER, -1.0f, UserHandle.USER_CURRENT);
-            if (volume >= 0.0f) {
-                AudioSystem.setMasterVolume(volume);
-            }
-        }
-    }
-
     /** @see AudioManager#shouldVibrate(int) */
     public boolean shouldVibrate(int vibrateType) {
         if (!mHasVibrator) return false;
@@ -3510,9 +3350,8 @@
 
         public void readSettings() {
             synchronized (VolumeStreamState.class) {
-                // force maximum volume on all streams if fixed volume property
-                // or master volume property is set
-                if (mUseFixedVolume || mUseMasterVolume) {
+                // force maximum volume on all streams if fixed volume property is set
+                if (mUseFixedVolume) {
                     mIndexMap.put(AudioSystem.DEVICE_OUT_DEFAULT, mIndexMax);
                     return;
                 }
@@ -3747,7 +3586,7 @@
         private int getValidIndex(int index) {
             if (index < 0) {
                 return 0;
-            } else if (mUseFixedVolume || mUseMasterVolume || index > mIndexMax) {
+            } else if (mUseFixedVolume || index > mIndexMax) {
                 return mIndexMax;
             }
 
@@ -4119,16 +3958,6 @@
                     persistVolume((VolumeStreamState) msg.obj, msg.arg1);
                     break;
 
-                case MSG_PERSIST_MASTER_VOLUME:
-                    if (mUseFixedVolume) {
-                        return;
-                    }
-                    Settings.System.putFloatForUser(mContentResolver,
-                                                    Settings.System.VOLUME_MASTER,
-                                                    msg.arg1 / (float)1000.0,
-                                                    UserHandle.USER_CURRENT);
-                    break;
-
                 case MSG_PERSIST_MASTER_VOLUME_MUTE:
                     if (mUseFixedVolume) {
                         return;
@@ -4197,9 +4026,6 @@
                     // Restore ringer mode
                     setRingerModeInt(getRingerModeInternal(), false);
 
-                    // Restore master volume
-                    restoreMasterVolume();
-
                     // Reset device orientation (if monitored for this device)
                     if (mMonitorOrientation) {
                         setOrientationForAudioSystem();
@@ -5666,16 +5492,6 @@
             }
         }
 
-        public void postMasterVolumeChanged(int flags) {
-            if (mController == null)
-                return;
-            try {
-                mController.masterVolumeChanged(flags);
-            } catch (RemoteException e) {
-                Log.w(TAG, "Error calling masterVolumeChanged", e);
-            }
-        }
-
         public void postMasterMuteChanged(int flags) {
             if (mController == null)
                 return;
@@ -5741,12 +5557,6 @@
         }
 
         @Override
-        public void adjustMasterVolumeForUid(int steps, int flags, String callingPackage,
-                int uid) {
-            adjustMasterVolume(steps, flags, callingPackage, uid);
-        }
-
-        @Override
         public int getRingerModeInternal() {
             return AudioService.this.getRingerModeInternal();
         }
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java
index 3345e46..5363968 100644
--- a/services/core/java/com/android/server/media/MediaSessionRecord.java
+++ b/services/core/java/com/android/server/media/MediaSessionRecord.java
@@ -90,14 +90,12 @@
     private final SessionStub mSession;
     private final SessionCb mSessionCb;
     private final MediaSessionService mService;
-    private final boolean mUseMasterVolume;
 
     private final Object mLock = new Object();
     private final ArrayList<ISessionControllerCallback> mControllerCallbacks =
             new ArrayList<ISessionControllerCallback>();
 
     private long mFlags;
-    private IMediaRouter mMediaRouter;
     private PendingIntent mMediaButtonReceiver;
     private PendingIntent mLaunchIntent;
 
@@ -141,8 +139,6 @@
         mAudioManager = (AudioManager) service.getContext().getSystemService(Context.AUDIO_SERVICE);
         mAudioManagerInternal = LocalServices.getService(AudioManagerInternal.class);
         mAudioAttrs = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_MEDIA).build();
-        mUseMasterVolume = service.getContext().getResources().getBoolean(
-                com.android.internal.R.bool.config_useMasterVolume);
     }
 
     /**
@@ -247,13 +243,6 @@
             flags &= ~AudioManager.FLAG_PLAY_SOUND;
         }
         if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) {
-            if (mUseMasterVolume) {
-                // If this device only uses master volume and playback is local
-                // just adjust the master volume and return.
-                mAudioManagerInternal.adjustMasterVolumeForUid(direction, flags, packageName,
-                        uid);
-                return;
-            }
             int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs);
             if (useSuggested) {
                 if (AudioSystem.isStreamActive(stream, 0)) {
@@ -729,7 +718,6 @@
 
         @Override
         public void setMediaRouter(IMediaRouter router) {
-            mMediaRouter = router;
             mHandler.post(MessageHandler.MSG_UPDATE_SESSION_STATE);
         }
 
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index 4383bb1..72205d6 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -89,11 +89,9 @@
     private final Object mLock = new Object();
     private final MessageHandler mHandler = new MessageHandler();
     private final PowerManager.WakeLock mMediaEventWakeLock;
-    private final boolean mUseMasterVolume;
 
     private KeyguardManager mKeyguardManager;
     private IAudioService mAudioService;
-    private AudioManager mAudioManager;
     private AudioManagerInternal mAudioManagerInternal;
     private ContentResolver mContentResolver;
     private SettingsObserver mSettingsObserver;
@@ -110,8 +108,6 @@
         mPriorityStack = new MediaSessionStack();
         PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
         mMediaEventWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "handleMediaEvent");
-        mUseMasterVolume = context.getResources().getBoolean(
-                com.android.internal.R.bool.config_useMasterVolume);
     }
 
     @Override
@@ -121,7 +117,6 @@
         mKeyguardManager =
                 (KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE);
         mAudioService = getAudioService();
-        mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
         mAudioManagerInternal = LocalServices.getService(AudioManagerInternal.class);
         mContentResolver = getContext().getContentResolver();
         mSettingsObserver = new SettingsObserver();
@@ -468,11 +463,6 @@
         return -1;
     }
 
-    private boolean isSessionDiscoverable(MediaSessionRecord record) {
-        // TODO probably want to check more than if it's active.
-        return record.isActive();
-    }
-
     private void pushSessionsChanged(int userId) {
         synchronized (mLock) {
             List<MediaSessionRecord> records = mPriorityStack.getActiveSessions(userId);
@@ -889,12 +879,8 @@
                 }
                 try {
                     String packageName = getContext().getOpPackageName();
-                    if (mUseMasterVolume) {
-                            mAudioService.adjustMasterVolume(direction, flags, packageName);
-                    } else {
-                        mAudioService.adjustSuggestedStreamVolume(direction, suggestedStream,
-                                flags, packageName);
-                    }
+                    mAudioService.adjustSuggestedStreamVolume(direction, suggestedStream,
+                            flags, packageName);
                 } catch (RemoteException e) {
                     Log.e(TAG, "Error adjusting default volume.", e);
                 }
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 5185cf6..1198110 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -380,7 +380,6 @@
     boolean mHasSoftInput = false;
     boolean mTranslucentDecorEnabled = true;
     boolean mUseTvRouting;
-    boolean mUseMasterVolume;
 
     int mPointerLocationMode = 0; // guarded by mLock
 
@@ -1270,8 +1269,6 @@
                 com.android.internal.R.integer.config_triplePressOnPowerBehavior);
 
         mUseTvRouting = AudioSystem.getPlatformType(mContext) == AudioSystem.PLATFORM_TELEVISION;
-        mUseMasterVolume = mContext.getResources().getBoolean(
-                com.android.internal.R.bool.config_useMasterVolume);
 
         readConfigurationDependentBehaviors();
 
@@ -4859,26 +4856,16 @@
         switch (keyCode) {
             case KeyEvent.KEYCODE_VOLUME_UP:
                 try {
-                    if (mUseMasterVolume) {
-                        getAudioService().adjustMasterVolume(AudioManager.ADJUST_RAISE, flags,
-                                pkgName);
-                    } else {
-                        getAudioService().adjustSuggestedStreamVolume(AudioManager.ADJUST_RAISE,
-                                AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName);
-                    }
+                    getAudioService().adjustSuggestedStreamVolume(AudioManager.ADJUST_RAISE,
+                            AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName);
                 } catch (RemoteException e) {
                     Log.e(TAG, "Error dispatching volume up in dispatchTvAudioEvent.", e);
                 }
                 break;
             case KeyEvent.KEYCODE_VOLUME_DOWN:
                 try {
-                    if (mUseMasterVolume) {
-                        getAudioService().adjustMasterVolume(AudioManager.ADJUST_LOWER, flags,
-                                pkgName);
-                    } else {
-                        getAudioService().adjustSuggestedStreamVolume(AudioManager.ADJUST_LOWER,
-                                AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName);
-                    }
+                    getAudioService().adjustSuggestedStreamVolume(AudioManager.ADJUST_LOWER,
+                            AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName);
                 } catch (RemoteException e) {
                     Log.e(TAG, "Error dispatching volume down in dispatchTvAudioEvent.", e);
                 }
@@ -4886,14 +4873,9 @@
             case KeyEvent.KEYCODE_VOLUME_MUTE:
                 try {
                     if (event.getRepeatCount() == 0) {
-                        if (mUseMasterVolume) {
-                            getAudioService().adjustMasterVolume(AudioManager.ADJUST_TOGGLE_MUTE,
-                                    flags, pkgName);
-                        } else {
-                            getAudioService().adjustSuggestedStreamVolume(
-                                    AudioManager.ADJUST_TOGGLE_MUTE,
-                                    AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName);
-                        }
+                        getAudioService().adjustSuggestedStreamVolume(
+                                AudioManager.ADJUST_TOGGLE_MUTE,
+                                AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName);
                     }
                 } catch (RemoteException e) {
                     Log.e(TAG, "Error dispatching mute in dispatchTvAudioEvent.", e);
diff --git a/services/core/java/com/android/server/tv/TvInputHardwareManager.java b/services/core/java/com/android/server/tv/TvInputHardwareManager.java
index e57396f..ac8ad30 100644
--- a/services/core/java/com/android/server/tv/TvInputHardwareManager.java
+++ b/services/core/java/com/android/server/tv/TvInputHardwareManager.java
@@ -102,7 +102,6 @@
     };
     private int mCurrentIndex = 0;
     private int mCurrentMaxIndex = 0;
-    private final boolean mUseMasterVolume;
 
     // TODO: Should handle STANDBY case.
     private final SparseBooleanArray mHdmiStateMap = new SparseBooleanArray();
@@ -117,8 +116,6 @@
         mContext = context;
         mListener = listener;
         mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
-        mUseMasterVolume = mContext.getResources().getBoolean(
-                com.android.internal.R.bool.config_useMasterVolume);
         mHal.init();
     }
 
@@ -139,12 +136,10 @@
             } else {
                 Slog.w(TAG, "HdmiControlService is not available");
             }
-            if (!mUseMasterVolume) {
-                final IntentFilter filter = new IntentFilter();
-                filter.addAction(AudioManager.VOLUME_CHANGED_ACTION);
-                filter.addAction(AudioManager.STREAM_MUTE_CHANGED_ACTION);
-                mContext.registerReceiver(mVolumeReceiver, filter);
-            }
+            final IntentFilter filter = new IntentFilter();
+            filter.addAction(AudioManager.VOLUME_CHANGED_ACTION);
+            filter.addAction(AudioManager.STREAM_MUTE_CHANGED_ACTION);
+            mContext.registerReceiver(mVolumeReceiver, filter);
             updateVolume();
         }
     }
@@ -545,7 +540,7 @@
     }
 
     private float getMediaStreamVolume() {
-        return mUseMasterVolume ? 1.0f : ((float) mCurrentIndex / (float) mCurrentMaxIndex);
+        return (float) mCurrentIndex / (float) mCurrentMaxIndex;
     }
 
     private class Connection implements IBinder.DeathRecipient {