Loading services/core/java/com/android/server/media/MediaSessionRecord.java +96 −78 Original line number Diff line number Diff line Loading @@ -431,28 +431,9 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde int stream = getVolumeStream(mAudioAttrs); final int volumeValue = value; mHandler.post( new Runnable() { @Override public void run() { try { mAudioManager.setStreamVolumeForUid( stream, volumeValue, flags, opPackageName, uid, pid, mContext.getApplicationInfo().targetSdkVersion); } catch (IllegalArgumentException | SecurityException e) { Slog.e( TAG, "Cannot set volume: stream=" + stream + ", value=" + volumeValue + ", flags=" + flags, e); } } }); () -> setStreamVolumeForUid( opPackageName, pid, uid, flags, stream, volumeValue)); } else { if (mVolumeControlType != VOLUME_CONTROL_ABSOLUTE) { if (DEBUG) { Loading Loading @@ -482,6 +463,27 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde } } private void setStreamVolumeForUid( String opPackageName, int pid, int uid, int flags, int stream, int volumeValue) { try { mAudioManager.setStreamVolumeForUid( stream, volumeValue, flags, opPackageName, uid, pid, mContext.getApplicationInfo().targetSdkVersion); } catch (IllegalArgumentException | SecurityException e) { Slog.e( TAG, "Cannot set volume: stream=" + stream + ", value=" + volumeValue + ", flags=" + flags, e); } } /** * Check if this session has been set to active by the app. * <p> Loading Loading @@ -749,9 +751,27 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde pid = callingPid; } mHandler.post( new Runnable() { @Override public void run() { () -> adjustSuggestedStreamVolumeForUid( stream, direction, flags, useSuggested, previousFlagPlaySound, opPackageName, uid, pid)); } private void adjustSuggestedStreamVolumeForUid( int stream, int direction, int flags, boolean useSuggested, int previousFlagPlaySound, String opPackageName, int uid, int pid) { try { if (useSuggested) { if (AudioSystem.isStreamActive(stream, 0)) { Loading Loading @@ -787,15 +807,15 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde Slog.e( TAG, "Cannot adjust volume: direction=" + direction + ", stream=" + stream + ", flags=" + flags + ", opPackageName=" + opPackageName + ", uid=" + uid + ", stream=" + stream + ", flags=" + flags + ", opPackageName=" + opPackageName + ", uid=" + uid + ", useSuggested=" + useSuggested + ", previousFlagPlaySound=" + previousFlagPlaySound, e); } } }); } private void logCallbackException( String msg, ISessionControllerCallbackHolder holder, Exception e) { Loading Loading @@ -1089,15 +1109,13 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde volumeType, VOLUME_CONTROL_ABSOLUTE, max, current, attributes, null); } private final Runnable mClearOptimisticVolumeRunnable = new Runnable() { @Override public void run() { private final Runnable mClearOptimisticVolumeRunnable = () -> { boolean needUpdate = (mOptimisticVolume != mCurrentVolume); mOptimisticVolume = -1; if (needUpdate) { pushVolumeUpdate(); } } }; @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) Loading Loading
services/core/java/com/android/server/media/MediaSessionRecord.java +96 −78 Original line number Diff line number Diff line Loading @@ -431,28 +431,9 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde int stream = getVolumeStream(mAudioAttrs); final int volumeValue = value; mHandler.post( new Runnable() { @Override public void run() { try { mAudioManager.setStreamVolumeForUid( stream, volumeValue, flags, opPackageName, uid, pid, mContext.getApplicationInfo().targetSdkVersion); } catch (IllegalArgumentException | SecurityException e) { Slog.e( TAG, "Cannot set volume: stream=" + stream + ", value=" + volumeValue + ", flags=" + flags, e); } } }); () -> setStreamVolumeForUid( opPackageName, pid, uid, flags, stream, volumeValue)); } else { if (mVolumeControlType != VOLUME_CONTROL_ABSOLUTE) { if (DEBUG) { Loading Loading @@ -482,6 +463,27 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde } } private void setStreamVolumeForUid( String opPackageName, int pid, int uid, int flags, int stream, int volumeValue) { try { mAudioManager.setStreamVolumeForUid( stream, volumeValue, flags, opPackageName, uid, pid, mContext.getApplicationInfo().targetSdkVersion); } catch (IllegalArgumentException | SecurityException e) { Slog.e( TAG, "Cannot set volume: stream=" + stream + ", value=" + volumeValue + ", flags=" + flags, e); } } /** * Check if this session has been set to active by the app. * <p> Loading Loading @@ -749,9 +751,27 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde pid = callingPid; } mHandler.post( new Runnable() { @Override public void run() { () -> adjustSuggestedStreamVolumeForUid( stream, direction, flags, useSuggested, previousFlagPlaySound, opPackageName, uid, pid)); } private void adjustSuggestedStreamVolumeForUid( int stream, int direction, int flags, boolean useSuggested, int previousFlagPlaySound, String opPackageName, int uid, int pid) { try { if (useSuggested) { if (AudioSystem.isStreamActive(stream, 0)) { Loading Loading @@ -787,15 +807,15 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde Slog.e( TAG, "Cannot adjust volume: direction=" + direction + ", stream=" + stream + ", flags=" + flags + ", opPackageName=" + opPackageName + ", uid=" + uid + ", stream=" + stream + ", flags=" + flags + ", opPackageName=" + opPackageName + ", uid=" + uid + ", useSuggested=" + useSuggested + ", previousFlagPlaySound=" + previousFlagPlaySound, e); } } }); } private void logCallbackException( String msg, ISessionControllerCallbackHolder holder, Exception e) { Loading Loading @@ -1089,15 +1109,13 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde volumeType, VOLUME_CONTROL_ABSOLUTE, max, current, attributes, null); } private final Runnable mClearOptimisticVolumeRunnable = new Runnable() { @Override public void run() { private final Runnable mClearOptimisticVolumeRunnable = () -> { boolean needUpdate = (mOptimisticVolume != mCurrentVolume); mOptimisticVolume = -1; if (needUpdate) { pushVolumeUpdate(); } } }; @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) Loading