Loading services/core/java/com/android/server/audio/AudioService.java +38 −18 Original line number Diff line number Diff line Loading @@ -3980,7 +3980,8 @@ public class AudioService extends IAudioService.Stub } setStreamVolume(groupedStream, index, flags, /*device*/ null, callingPackage, callingPackage, attributionTag, Binder.getCallingUid(), true /*hasModifyAudioSettings*/); attributionTag, Binder.getCallingUid(), true /*hasModifyAudioSettings*/, true /*canChangeMuteAndUpdateController*/); } } Loading Loading @@ -4099,7 +4100,9 @@ public class AudioService extends IAudioService.Stub setStreamVolumeWithAttributionInt(vi.getStreamType(), mStreamStates[vi.getStreamType()].getMinIndex(), /*flags*/ 0, ada, callingPackage, null); ada, callingPackage, null, //TODO handle unmuting of current audio device false /*canChangeMuteAndUpdateController*/); return; } Loading @@ -4125,7 +4128,8 @@ public class AudioService extends IAudioService.Stub } } setStreamVolumeWithAttributionInt(vi.getStreamType(), index, /*flags*/ 0, ada, callingPackage, null); ada, callingPackage, null, false /*canChangeMuteAndUpdateController*/); } /** Retain API for unsupported app usage */ Loading Loading @@ -4204,7 +4208,7 @@ public class AudioService extends IAudioService.Stub public void setStreamVolumeWithAttribution(int streamType, int index, int flags, String callingPackage, String attributionTag) { setStreamVolumeWithAttributionInt(streamType, index, flags, /*device*/ null, callingPackage, attributionTag); callingPackage, attributionTag, true /*canChangeMuteAndUpdateController*/); } /** Loading @@ -4217,10 +4221,18 @@ public class AudioService extends IAudioService.Stub * for which volume is being changed * @param callingPackage client side-provided package name of caller, not to be trusted * @param attributionTag client side-provided attribution name, not to be trusted * @param canChangeMuteAndUpdateController true if the calling method is a path where * the volume change is allowed to update the mute state as well as update * the volume controller (the UI). This is intended to be true for a call coming * from AudioManager.setStreamVolume (which is here * {@link #setStreamVolumeForUid(int, int, int, String, int, int, UserHandle, int)}, * and false when coming from AudioDeviceVolumeManager.setDeviceVolume (which is here * {@link #setDeviceVolume(VolumeInfo, AudioDeviceAttributes, String)} */ protected void setStreamVolumeWithAttributionInt(int streamType, int index, int flags, @Nullable AudioDeviceAttributes device, String callingPackage, String attributionTag) { @Nullable AudioDeviceAttributes ada, String callingPackage, String attributionTag, boolean canChangeMuteAndUpdateController) { if ((streamType == AudioManager.STREAM_ACCESSIBILITY) && !canChangeAccessibilityVolume()) { Log.w(TAG, "Trying to call setStreamVolume() for a11y without" + " CHANGE_ACCESSIBILITY_VOLUME callingPackage=" + callingPackage); Loading @@ -4243,15 +4255,18 @@ public class AudioService extends IAudioService.Stub return; } if (device == null) { if (ada == null) { // call was already logged in setDeviceVolume() final int deviceType = getDeviceForStream(streamType); sVolumeLogger.enqueue(new VolumeEvent(VolumeEvent.VOL_SET_STREAM_VOL, streamType, index/*val1*/, flags/*val2*/, getStreamVolume(streamType) /*val3*/, index/*val1*/, flags/*val2*/, getStreamVolume(streamType, deviceType) /*val3*/, callingPackage)); ada = new AudioDeviceAttributes(deviceType /*nativeType*/, "" /*address*/); } setStreamVolume(streamType, index, flags, device, setStreamVolume(streamType, index, flags, ada, callingPackage, callingPackage, attributionTag, Binder.getCallingUid(), callingOrSelfHasAudioSettingsPermission()); Binder.getCallingUid(), callingOrSelfHasAudioSettingsPermission(), canChangeMuteAndUpdateController); } @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_ULTRASOUND) Loading Loading @@ -4539,9 +4554,11 @@ public class AudioService extends IAudioService.Stub } private void setStreamVolume(int streamType, int index, int flags, @Nullable AudioDeviceAttributes ada, @NonNull AudioDeviceAttributes ada, String callingPackage, String caller, String attributionTag, int uid, boolean hasModifyAudioSettings) { boolean hasModifyAudioSettings, boolean canChangeMuteAndUpdateController) { if (DEBUG_VOL) { Log.d(TAG, "setStreamVolume(stream=" + streamType+", index=" + index + ", dev=" + ada Loading @@ -4555,9 +4572,7 @@ public class AudioService extends IAudioService.Stub int streamTypeAlias = mStreamVolumeAlias[streamType]; VolumeStreamState streamState = mStreamStates[streamTypeAlias]; final int device = (ada == null) ? getDeviceForStream(streamType) : ada.getInternalType(); final int device = ada.getInternalType(); int oldIndex; // skip a2dp absolute volume control request when the device Loading Loading @@ -4644,7 +4659,7 @@ public class AudioService extends IAudioService.Stub onSetStreamVolume(streamType, index, flags, device, caller, hasModifyAudioSettings, // ada is non-null when called from setDeviceVolume, // which shouldn't update the mute state ada == null /*canChangeMute*/); canChangeMuteAndUpdateController /*canChangeMute*/); index = mStreamStates[streamType].getIndex(device); } Loading @@ -4654,7 +4669,7 @@ public class AudioService extends IAudioService.Stub maybeSendSystemAudioStatusCommand(false); } } if (ada == null) { if (canChangeMuteAndUpdateController) { // only non-null when coming here from setDeviceVolume // TODO change test to check early if device is current device or not sendVolumeUpdate(streamType, oldIndex, index, flags, device); Loading Loading @@ -5067,6 +5082,10 @@ public class AudioService extends IAudioService.Stub public int getStreamVolume(int streamType) { ensureValidStreamType(streamType); int device = getDeviceForStream(streamType); return getStreamVolume(streamType, device); } private int getStreamVolume(int streamType, int device) { synchronized (VolumeStreamState.class) { int index = mStreamStates[streamType].getIndex(device); Loading Loading @@ -6185,7 +6204,8 @@ public class AudioService extends IAudioService.Stub setStreamVolume(streamType, index, flags, /*device*/ null, packageName, packageName, null, uid, hasAudioSettingsPermission(uid, pid)); hasAudioSettingsPermission(uid, pid), true /*canChangeMuteAndUpdateController*/); } //========================================================================================== Loading services/core/java/com/android/server/audio/SoundDoseHelper.java +2 −1 Original line number Diff line number Diff line Loading @@ -1297,7 +1297,8 @@ public class SoundDoseHelper { } final int index = safeMediaVolumeIndex(nativeDeviceType); mAudioService.setStreamVolumeWithAttributionInt(STREAM_MUSIC, index / 10, /*flags*/ 0, ada, mContext.getOpPackageName(), /*attributionTag=*/null); mContext.getOpPackageName(), /*attributionTag=*/null, true /*canChangeMuteAndUpdateController*/); } // StreamVolumeCommand contains the information needed to defer the process of Loading Loading
services/core/java/com/android/server/audio/AudioService.java +38 −18 Original line number Diff line number Diff line Loading @@ -3980,7 +3980,8 @@ public class AudioService extends IAudioService.Stub } setStreamVolume(groupedStream, index, flags, /*device*/ null, callingPackage, callingPackage, attributionTag, Binder.getCallingUid(), true /*hasModifyAudioSettings*/); attributionTag, Binder.getCallingUid(), true /*hasModifyAudioSettings*/, true /*canChangeMuteAndUpdateController*/); } } Loading Loading @@ -4099,7 +4100,9 @@ public class AudioService extends IAudioService.Stub setStreamVolumeWithAttributionInt(vi.getStreamType(), mStreamStates[vi.getStreamType()].getMinIndex(), /*flags*/ 0, ada, callingPackage, null); ada, callingPackage, null, //TODO handle unmuting of current audio device false /*canChangeMuteAndUpdateController*/); return; } Loading @@ -4125,7 +4128,8 @@ public class AudioService extends IAudioService.Stub } } setStreamVolumeWithAttributionInt(vi.getStreamType(), index, /*flags*/ 0, ada, callingPackage, null); ada, callingPackage, null, false /*canChangeMuteAndUpdateController*/); } /** Retain API for unsupported app usage */ Loading Loading @@ -4204,7 +4208,7 @@ public class AudioService extends IAudioService.Stub public void setStreamVolumeWithAttribution(int streamType, int index, int flags, String callingPackage, String attributionTag) { setStreamVolumeWithAttributionInt(streamType, index, flags, /*device*/ null, callingPackage, attributionTag); callingPackage, attributionTag, true /*canChangeMuteAndUpdateController*/); } /** Loading @@ -4217,10 +4221,18 @@ public class AudioService extends IAudioService.Stub * for which volume is being changed * @param callingPackage client side-provided package name of caller, not to be trusted * @param attributionTag client side-provided attribution name, not to be trusted * @param canChangeMuteAndUpdateController true if the calling method is a path where * the volume change is allowed to update the mute state as well as update * the volume controller (the UI). This is intended to be true for a call coming * from AudioManager.setStreamVolume (which is here * {@link #setStreamVolumeForUid(int, int, int, String, int, int, UserHandle, int)}, * and false when coming from AudioDeviceVolumeManager.setDeviceVolume (which is here * {@link #setDeviceVolume(VolumeInfo, AudioDeviceAttributes, String)} */ protected void setStreamVolumeWithAttributionInt(int streamType, int index, int flags, @Nullable AudioDeviceAttributes device, String callingPackage, String attributionTag) { @Nullable AudioDeviceAttributes ada, String callingPackage, String attributionTag, boolean canChangeMuteAndUpdateController) { if ((streamType == AudioManager.STREAM_ACCESSIBILITY) && !canChangeAccessibilityVolume()) { Log.w(TAG, "Trying to call setStreamVolume() for a11y without" + " CHANGE_ACCESSIBILITY_VOLUME callingPackage=" + callingPackage); Loading @@ -4243,15 +4255,18 @@ public class AudioService extends IAudioService.Stub return; } if (device == null) { if (ada == null) { // call was already logged in setDeviceVolume() final int deviceType = getDeviceForStream(streamType); sVolumeLogger.enqueue(new VolumeEvent(VolumeEvent.VOL_SET_STREAM_VOL, streamType, index/*val1*/, flags/*val2*/, getStreamVolume(streamType) /*val3*/, index/*val1*/, flags/*val2*/, getStreamVolume(streamType, deviceType) /*val3*/, callingPackage)); ada = new AudioDeviceAttributes(deviceType /*nativeType*/, "" /*address*/); } setStreamVolume(streamType, index, flags, device, setStreamVolume(streamType, index, flags, ada, callingPackage, callingPackage, attributionTag, Binder.getCallingUid(), callingOrSelfHasAudioSettingsPermission()); Binder.getCallingUid(), callingOrSelfHasAudioSettingsPermission(), canChangeMuteAndUpdateController); } @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_ULTRASOUND) Loading Loading @@ -4539,9 +4554,11 @@ public class AudioService extends IAudioService.Stub } private void setStreamVolume(int streamType, int index, int flags, @Nullable AudioDeviceAttributes ada, @NonNull AudioDeviceAttributes ada, String callingPackage, String caller, String attributionTag, int uid, boolean hasModifyAudioSettings) { boolean hasModifyAudioSettings, boolean canChangeMuteAndUpdateController) { if (DEBUG_VOL) { Log.d(TAG, "setStreamVolume(stream=" + streamType+", index=" + index + ", dev=" + ada Loading @@ -4555,9 +4572,7 @@ public class AudioService extends IAudioService.Stub int streamTypeAlias = mStreamVolumeAlias[streamType]; VolumeStreamState streamState = mStreamStates[streamTypeAlias]; final int device = (ada == null) ? getDeviceForStream(streamType) : ada.getInternalType(); final int device = ada.getInternalType(); int oldIndex; // skip a2dp absolute volume control request when the device Loading Loading @@ -4644,7 +4659,7 @@ public class AudioService extends IAudioService.Stub onSetStreamVolume(streamType, index, flags, device, caller, hasModifyAudioSettings, // ada is non-null when called from setDeviceVolume, // which shouldn't update the mute state ada == null /*canChangeMute*/); canChangeMuteAndUpdateController /*canChangeMute*/); index = mStreamStates[streamType].getIndex(device); } Loading @@ -4654,7 +4669,7 @@ public class AudioService extends IAudioService.Stub maybeSendSystemAudioStatusCommand(false); } } if (ada == null) { if (canChangeMuteAndUpdateController) { // only non-null when coming here from setDeviceVolume // TODO change test to check early if device is current device or not sendVolumeUpdate(streamType, oldIndex, index, flags, device); Loading Loading @@ -5067,6 +5082,10 @@ public class AudioService extends IAudioService.Stub public int getStreamVolume(int streamType) { ensureValidStreamType(streamType); int device = getDeviceForStream(streamType); return getStreamVolume(streamType, device); } private int getStreamVolume(int streamType, int device) { synchronized (VolumeStreamState.class) { int index = mStreamStates[streamType].getIndex(device); Loading Loading @@ -6185,7 +6204,8 @@ public class AudioService extends IAudioService.Stub setStreamVolume(streamType, index, flags, /*device*/ null, packageName, packageName, null, uid, hasAudioSettingsPermission(uid, pid)); hasAudioSettingsPermission(uid, pid), true /*canChangeMuteAndUpdateController*/); } //========================================================================================== Loading
services/core/java/com/android/server/audio/SoundDoseHelper.java +2 −1 Original line number Diff line number Diff line Loading @@ -1297,7 +1297,8 @@ public class SoundDoseHelper { } final int index = safeMediaVolumeIndex(nativeDeviceType); mAudioService.setStreamVolumeWithAttributionInt(STREAM_MUSIC, index / 10, /*flags*/ 0, ada, mContext.getOpPackageName(), /*attributionTag=*/null); mContext.getOpPackageName(), /*attributionTag=*/null, true /*canChangeMuteAndUpdateController*/); } // StreamVolumeCommand contains the information needed to defer the process of Loading