Loading services/core/java/com/android/server/media/MediaSessionRecord.java +46 −39 Original line number Diff line number Diff line Loading @@ -291,15 +291,14 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR asSystemService, useSuggested, previousFlagPlaySound); } else { if (mVolumeControlType == VolumeProvider.VOLUME_CONTROL_FIXED) { // Nothing to do, the volume cannot be changed return; if (DEBUG) { Log.d(TAG, "Session does not support volume adjustment"); } if (direction == AudioManager.ADJUST_TOGGLE_MUTE } else if (direction == AudioManager.ADJUST_TOGGLE_MUTE || direction == AudioManager.ADJUST_MUTE || direction == AudioManager.ADJUST_UNMUTE) { Log.w(TAG, "Muting remote playback is not supported"); return; } } else { if (DEBUG) { Log.w(TAG, "adjusting volume, pkg=" + packageName + ", asSystemService=" + asSystemService + ", dir=" + direction); Loading @@ -314,13 +313,18 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR if (volumeBefore != mOptimisticVolume) { pushVolumeUpdate(); } mService.notifyRemoteVolumeChanged(flags, this); if (DEBUG) { Log.d(TAG, "Adjusted optimistic volume to " + mOptimisticVolume + " max is " + mMaxVolume); } } // Always notify, even if the volume hasn't changed. This is important to ensure that // System UI receives an event if a hardware volume key is pressed but the session that // handles it does not allow volume adjustment. Without such an event, System UI would // not show volume controls to the user. mService.notifyRemoteVolumeChanged(flags, this); } } private void setVolumeTo(String packageName, String opPackageName, int pid, int uid, int value, Loading @@ -343,9 +347,10 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR }); } else { if (mVolumeControlType != VolumeProvider.VOLUME_CONTROL_ABSOLUTE) { // Nothing to do. The volume can't be set directly. return; if (DEBUG) { Log.d(TAG, "Session does not support setting volume"); } } else { value = Math.max(0, Math.min(value, mMaxVolume)); mSessionCb.setVolumeTo(packageName, pid, uid, value); Loading @@ -356,13 +361,15 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR if (volumeBefore != mOptimisticVolume) { pushVolumeUpdate(); } mService.notifyRemoteVolumeChanged(flags, this); if (DEBUG) { Log.d(TAG, "Set optimistic volume to " + mOptimisticVolume + " max is " + mMaxVolume); } } // Always notify, even if the volume hasn't changed. mService.notifyRemoteVolumeChanged(flags, this); } } /** Loading Loading
services/core/java/com/android/server/media/MediaSessionRecord.java +46 −39 Original line number Diff line number Diff line Loading @@ -291,15 +291,14 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR asSystemService, useSuggested, previousFlagPlaySound); } else { if (mVolumeControlType == VolumeProvider.VOLUME_CONTROL_FIXED) { // Nothing to do, the volume cannot be changed return; if (DEBUG) { Log.d(TAG, "Session does not support volume adjustment"); } if (direction == AudioManager.ADJUST_TOGGLE_MUTE } else if (direction == AudioManager.ADJUST_TOGGLE_MUTE || direction == AudioManager.ADJUST_MUTE || direction == AudioManager.ADJUST_UNMUTE) { Log.w(TAG, "Muting remote playback is not supported"); return; } } else { if (DEBUG) { Log.w(TAG, "adjusting volume, pkg=" + packageName + ", asSystemService=" + asSystemService + ", dir=" + direction); Loading @@ -314,13 +313,18 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR if (volumeBefore != mOptimisticVolume) { pushVolumeUpdate(); } mService.notifyRemoteVolumeChanged(flags, this); if (DEBUG) { Log.d(TAG, "Adjusted optimistic volume to " + mOptimisticVolume + " max is " + mMaxVolume); } } // Always notify, even if the volume hasn't changed. This is important to ensure that // System UI receives an event if a hardware volume key is pressed but the session that // handles it does not allow volume adjustment. Without such an event, System UI would // not show volume controls to the user. mService.notifyRemoteVolumeChanged(flags, this); } } private void setVolumeTo(String packageName, String opPackageName, int pid, int uid, int value, Loading @@ -343,9 +347,10 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR }); } else { if (mVolumeControlType != VolumeProvider.VOLUME_CONTROL_ABSOLUTE) { // Nothing to do. The volume can't be set directly. return; if (DEBUG) { Log.d(TAG, "Session does not support setting volume"); } } else { value = Math.max(0, Math.min(value, mMaxVolume)); mSessionCb.setVolumeTo(packageName, pid, uid, value); Loading @@ -356,13 +361,15 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR if (volumeBefore != mOptimisticVolume) { pushVolumeUpdate(); } mService.notifyRemoteVolumeChanged(flags, this); if (DEBUG) { Log.d(TAG, "Set optimistic volume to " + mOptimisticVolume + " max is " + mMaxVolume); } } // Always notify, even if the volume hasn't changed. mService.notifyRemoteVolumeChanged(flags, this); } } /** Loading