Loading services/core/java/com/android/server/audio/AudioService.java +38 −38 Original line number Original line Diff line number Diff line Loading @@ -1078,7 +1078,7 @@ public class AudioService extends IAudioService.Stub // Restore call state // Restore call state synchronized (mDeviceBroker.mSetModeLock) { synchronized (mDeviceBroker.mSetModeLock) { if (AudioSystem.setPhoneState(mMode, getModeOwnerUid()) if (mAudioSystem.setPhoneState(mMode, getModeOwnerUid()) == AudioSystem.AUDIO_STATUS_OK) { == AudioSystem.AUDIO_STATUS_OK) { mModeLogger.log(new AudioEventLogger.StringEvent( mModeLogger.log(new AudioEventLogger.StringEvent( "onAudioServerDied causes setPhoneState(" + AudioSystem.modeToString(mMode) "onAudioServerDied causes setPhoneState(" + AudioSystem.modeToString(mMode) Loading Loading @@ -1165,7 +1165,7 @@ public class AudioService extends IAudioService.Stub HashMap<Integer, Integer> allowedCapturePolicies = HashMap<Integer, Integer> allowedCapturePolicies = mPlaybackMonitor.getAllAllowedCapturePolicies(); mPlaybackMonitor.getAllAllowedCapturePolicies(); for (HashMap.Entry<Integer, Integer> entry : allowedCapturePolicies.entrySet()) { for (HashMap.Entry<Integer, Integer> entry : allowedCapturePolicies.entrySet()) { int result = AudioSystem.setAllowedCapturePolicy( int result = mAudioSystem.setAllowedCapturePolicy( entry.getKey(), entry.getKey(), AudioAttributes.capturePolicyToFlags(entry.getValue(), 0x0)); AudioAttributes.capturePolicyToFlags(entry.getValue(), 0x0)); if (result != AudioSystem.AUDIO_STATUS_OK) { if (result != AudioSystem.AUDIO_STATUS_OK) { Loading Loading @@ -2112,7 +2112,7 @@ public class AudioService extends IAudioService.Stub protected @NonNull ArrayList<AudioDeviceAttributes> getDevicesForAttributesInt( protected @NonNull ArrayList<AudioDeviceAttributes> getDevicesForAttributesInt( @NonNull AudioAttributes attributes) { @NonNull AudioAttributes attributes) { Objects.requireNonNull(attributes); Objects.requireNonNull(attributes); return AudioSystem.getDevicesForAttributes(attributes); return mAudioSystem.getDevicesForAttributes(attributes); } } /** Indicates no special treatment in the handling of the volume adjustement */ /** Indicates no special treatment in the handling of the volume adjustement */ Loading Loading @@ -2219,7 +2219,7 @@ public class AudioService extends IAudioService.Stub || maybeActiveStreamType == AudioSystem.STREAM_NOTIFICATION) { || maybeActiveStreamType == AudioSystem.STREAM_NOTIFICATION) { activeForReal = wasStreamActiveRecently(maybeActiveStreamType, 0); activeForReal = wasStreamActiveRecently(maybeActiveStreamType, 0); } else { } else { activeForReal = AudioSystem.isStreamActive(maybeActiveStreamType, 0); activeForReal = mAudioSystem.isStreamActive(maybeActiveStreamType, 0); } } if (activeForReal || mVolumeControlStream == -1) { if (activeForReal || mVolumeControlStream == -1) { streamType = maybeActiveStreamType; streamType = maybeActiveStreamType; Loading Loading @@ -2916,7 +2916,7 @@ public class AudioService extends IAudioService.Stub int streamType = getHearingAidStreamType(newMode); int streamType = getHearingAidStreamType(newMode); final Set<Integer> deviceTypes = AudioSystem.generateAudioDeviceTypesSet( final Set<Integer> deviceTypes = AudioSystem.generateAudioDeviceTypesSet( AudioSystem.getDevicesForStream(streamType)); mAudioSystem.getDevicesForStream(streamType)); final Set<Integer> absVolumeMultiModeCaseDevices = AudioSystem.intersectionAudioDeviceTypes( final Set<Integer> absVolumeMultiModeCaseDevices = AudioSystem.intersectionAudioDeviceTypes( mAbsVolumeMultiModeCaseDevices, deviceTypes); mAbsVolumeMultiModeCaseDevices, deviceTypes); if (absVolumeMultiModeCaseDevices.isEmpty()) { if (absVolumeMultiModeCaseDevices.isEmpty()) { Loading Loading @@ -4123,7 +4123,7 @@ public class AudioService extends IAudioService.Stub if (actualMode != mMode) { if (actualMode != mMode) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); status = AudioSystem.setPhoneState(actualMode, getModeOwnerUid()); status = mAudioSystem.setPhoneState(actualMode, getModeOwnerUid()); Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); if (status == AudioSystem.AUDIO_STATUS_OK) { if (status == AudioSystem.AUDIO_STATUS_OK) { if (DEBUG_MODE) { Log.v(TAG, " mode successfully set to " + actualMode); } if (DEBUG_MODE) { Log.v(TAG, " mode successfully set to " + actualMode); } Loading Loading @@ -4597,7 +4597,7 @@ public class AudioService extends IAudioService.Stub caller, caller, MUSIC_ACTIVE_POLL_PERIOD_MS); MUSIC_ACTIVE_POLL_PERIOD_MS); int index = mStreamStates[AudioSystem.STREAM_MUSIC].getIndex(device); int index = mStreamStates[AudioSystem.STREAM_MUSIC].getIndex(device); if (AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0) if (mAudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0) && (index > safeMediaVolumeIndex(device))) { && (index > safeMediaVolumeIndex(device))) { // Approximate cumulative active music time // Approximate cumulative active music time mMusicActiveMs += MUSIC_ACTIVE_POLL_PERIOD_MS; mMusicActiveMs += MUSIC_ACTIVE_POLL_PERIOD_MS; Loading Loading @@ -4981,8 +4981,8 @@ public class AudioService extends IAudioService.Stub * in the last "delay_ms" ms. * in the last "delay_ms" ms. */ */ private boolean wasStreamActiveRecently(int stream, int delay_ms) { private boolean wasStreamActiveRecently(int stream, int delay_ms) { return AudioSystem.isStreamActive(stream, delay_ms) return mAudioSystem.isStreamActive(stream, delay_ms) || AudioSystem.isStreamActiveRemotely(stream, delay_ms); || mAudioSystem.isStreamActiveRemotely(stream, delay_ms); } } private int getActiveStreamType(int suggestedStreamType) { private int getActiveStreamType(int suggestedStreamType) { Loading @@ -4994,7 +4994,7 @@ public class AudioService extends IAudioService.Stub switch (mPlatformType) { switch (mPlatformType) { case AudioSystem.PLATFORM_VOICE: case AudioSystem.PLATFORM_VOICE: if (isInCommunication()) { if (isInCommunication()) { if (AudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) if (mAudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) == AudioSystem.FORCE_BT_SCO) { == AudioSystem.FORCE_BT_SCO) { // Log.v(TAG, "getActiveStreamType: Forcing STREAM_BLUETOOTH_SCO..."); // Log.v(TAG, "getActiveStreamType: Forcing STREAM_BLUETOOTH_SCO..."); return AudioSystem.STREAM_BLUETOOTH_SCO; return AudioSystem.STREAM_BLUETOOTH_SCO; Loading Loading @@ -5031,7 +5031,7 @@ public class AudioService extends IAudioService.Stub } } default: default: if (isInCommunication()) { if (isInCommunication()) { if (AudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) if (mAudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) == AudioSystem.FORCE_BT_SCO) { == AudioSystem.FORCE_BT_SCO) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_BLUETOOTH_SCO"); if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_BLUETOOTH_SCO"); return AudioSystem.STREAM_BLUETOOTH_SCO; return AudioSystem.STREAM_BLUETOOTH_SCO; Loading @@ -5039,31 +5039,31 @@ public class AudioService extends IAudioService.Stub if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_VOICE_CALL"); if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_VOICE_CALL"); return AudioSystem.STREAM_VOICE_CALL; return AudioSystem.STREAM_VOICE_CALL; } } } else if (AudioSystem.isStreamActive( } else if (mAudioSystem.isStreamActive( AudioSystem.STREAM_NOTIFICATION, sStreamOverrideDelayMs)) { AudioSystem.STREAM_NOTIFICATION, sStreamOverrideDelayMs)) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_NOTIFICATION"); if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_NOTIFICATION"); return AudioSystem.STREAM_NOTIFICATION; return AudioSystem.STREAM_NOTIFICATION; } else if (AudioSystem.isStreamActive( } else if (mAudioSystem.isStreamActive( AudioSystem.STREAM_RING, sStreamOverrideDelayMs)) { AudioSystem.STREAM_RING, sStreamOverrideDelayMs)) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_RING"); if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_RING"); return AudioSystem.STREAM_RING; return AudioSystem.STREAM_RING; } else if (suggestedStreamType == AudioManager.USE_DEFAULT_STREAM_TYPE) { } else if (suggestedStreamType == AudioManager.USE_DEFAULT_STREAM_TYPE) { if (AudioSystem.isStreamActive( if (mAudioSystem.isStreamActive( AudioSystem.STREAM_NOTIFICATION, sStreamOverrideDelayMs)) { AudioSystem.STREAM_NOTIFICATION, sStreamOverrideDelayMs)) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_NOTIFICATION"); if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_NOTIFICATION"); return AudioSystem.STREAM_NOTIFICATION; return AudioSystem.STREAM_NOTIFICATION; } else if (AudioSystem.isStreamActive( } if (mAudioSystem.isStreamActive( AudioSystem.STREAM_RING, sStreamOverrideDelayMs)) { AudioSystem.STREAM_RING, sStreamOverrideDelayMs)) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_RING"); if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_RING"); return AudioSystem.STREAM_RING; return AudioSystem.STREAM_RING; } else { } if (DEBUG_VOL) { if (DEBUG_VOL) { Log.v(TAG, "getActiveStreamType: Forcing DEFAULT_VOL_STREAM_NO_PLAYBACK(" Log.v(TAG, "getActiveStreamType: Forcing DEFAULT_VOL_STREAM_NO_PLAYBACK(" + DEFAULT_VOL_STREAM_NO_PLAYBACK + ") b/c default"); + DEFAULT_VOL_STREAM_NO_PLAYBACK + ") b/c default"); } } return DEFAULT_VOL_STREAM_NO_PLAYBACK; return DEFAULT_VOL_STREAM_NO_PLAYBACK; } } } break; break; } } if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Returning suggested type " if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Returning suggested type " Loading Loading @@ -5477,7 +5477,7 @@ public class AudioService extends IAudioService.Stub && DEVICE_MEDIA_UNMUTED_ON_PLUG_SET.contains(newDevice) && DEVICE_MEDIA_UNMUTED_ON_PLUG_SET.contains(newDevice) && mStreamStates[AudioSystem.STREAM_MUSIC].mIsMuted && mStreamStates[AudioSystem.STREAM_MUSIC].mIsMuted && mStreamStates[AudioSystem.STREAM_MUSIC].getIndex(newDevice) != 0 && mStreamStates[AudioSystem.STREAM_MUSIC].getIndex(newDevice) != 0 && (newDevice & AudioSystem.getDevicesForStream(AudioSystem.STREAM_MUSIC)) != 0) { && (newDevice & mAudioSystem.getDevicesForStream(AudioSystem.STREAM_MUSIC)) != 0) { if (DEBUG_VOL) { if (DEBUG_VOL) { Log.i(TAG, String.format("onAccessoryPlugMediaUnmute unmuting device=%d [%s]", Log.i(TAG, String.format("onAccessoryPlugMediaUnmute unmuting device=%d [%s]", newDevice, AudioSystem.getOutputDeviceName(newDevice))); newDevice, AudioSystem.getOutputDeviceName(newDevice))); Loading Loading @@ -5945,7 +5945,7 @@ public class AudioService extends IAudioService.Stub if (!mSystemServer.isPrivileged()) { if (!mSystemServer.isPrivileged()) { return AudioSystem.DEVICE_NONE; return AudioSystem.DEVICE_NONE; } } final int devices = AudioSystem.getDevicesForStream(mStreamType); final int devices = mAudioSystem.getDevicesForStream(mStreamType); if (devices == mObservedDevices) { if (devices == mObservedDevices) { return devices; return devices; } } Loading Loading @@ -6670,7 +6670,7 @@ public class AudioService extends IAudioService.Stub .record(); .record(); sForceUseLogger.log( sForceUseLogger.log( new AudioServiceEvents.ForceUseEvent(useCase, config, eventSource)); new AudioServiceEvents.ForceUseEvent(useCase, config, eventSource)); AudioSystem.setForceUse(useCase, config); mAudioSystem.setForceUse(useCase, config); } } break; break; Loading Loading @@ -7993,7 +7993,7 @@ public class AudioService extends IAudioService.Stub } } } } public static class VolumeController { public class VolumeController { private static final String TAG = "VolumeController"; private static final String TAG = "VolumeController"; private IVolumeController mController; private IVolumeController mController; Loading Loading @@ -8033,7 +8033,7 @@ public class AudioService extends IAudioService.Stub if (resolvedStream == DEFAULT_VOL_STREAM_NO_PLAYBACK && mController != null) { if (resolvedStream == DEFAULT_VOL_STREAM_NO_PLAYBACK && mController != null) { // never suppress media vol adjustement during media playback // never suppress media vol adjustement during media playback if (resolvedStream == AudioSystem.STREAM_MUSIC if (resolvedStream == AudioSystem.STREAM_MUSIC && AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, mLongPressTimeout)) && mAudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, mLongPressTimeout)) { { // media is playing, adjust the volume right away // media is playing, adjust the volume right away return false; return false; Loading Loading @@ -8071,7 +8071,7 @@ public class AudioService extends IAudioService.Stub return binder(mController); return binder(mController); } } private static IBinder binder(IVolumeController controller) { private IBinder binder(IVolumeController controller) { return controller == null ? null : controller.asBinder(); return controller == null ? null : controller.asBinder(); } } Loading Loading @@ -8800,7 +8800,7 @@ public class AudioService extends IAudioService.Stub int flags = AudioAttributes.capturePolicyToFlags(capturePolicy, 0x0); int flags = AudioAttributes.capturePolicyToFlags(capturePolicy, 0x0); final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); synchronized (mPlaybackMonitor) { synchronized (mPlaybackMonitor) { int result = AudioSystem.setAllowedCapturePolicy(callingUid, flags); int result = mAudioSystem.setAllowedCapturePolicy(callingUid, flags); if (result == AudioSystem.AUDIO_STATUS_OK) { if (result == AudioSystem.AUDIO_STATUS_OK) { mPlaybackMonitor.setAllowedCapturePolicy(callingUid, capturePolicy); mPlaybackMonitor.setAllowedCapturePolicy(callingUid, capturePolicy); } } Loading Loading @@ -8943,7 +8943,7 @@ public class AudioService extends IAudioService.Stub } } } } final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); AudioSystem.registerPolicyMixes(mMixes, false); mAudioSystem.registerPolicyMixes(mMixes, false); Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); synchronized (mAudioPolicies) { synchronized (mAudioPolicies) { mAudioPolicies.remove(mPolicyCallback.asBinder()); mAudioPolicies.remove(mPolicyCallback.asBinder()); Loading Loading @@ -8986,24 +8986,24 @@ public class AudioService extends IAudioService.Stub int addMixes(@NonNull ArrayList<AudioMix> mixes) { int addMixes(@NonNull ArrayList<AudioMix> mixes) { // TODO optimize to not have to unregister the mixes already in place // TODO optimize to not have to unregister the mixes already in place synchronized (mMixes) { synchronized (mMixes) { AudioSystem.registerPolicyMixes(mMixes, false); mAudioSystem.registerPolicyMixes(mMixes, false); this.add(mixes); this.add(mixes); return AudioSystem.registerPolicyMixes(mMixes, true); return mAudioSystem.registerPolicyMixes(mMixes, true); } } } } int removeMixes(@NonNull ArrayList<AudioMix> mixes) { int removeMixes(@NonNull ArrayList<AudioMix> mixes) { // TODO optimize to not have to unregister the mixes already in place // TODO optimize to not have to unregister the mixes already in place synchronized (mMixes) { synchronized (mMixes) { AudioSystem.registerPolicyMixes(mMixes, false); mAudioSystem.registerPolicyMixes(mMixes, false); this.remove(mixes); this.remove(mixes); return AudioSystem.registerPolicyMixes(mMixes, true); return mAudioSystem.registerPolicyMixes(mMixes, true); } } } } @AudioSystem.AudioSystemError int connectMixes() { @AudioSystem.AudioSystemError int connectMixes() { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); int status = AudioSystem.registerPolicyMixes(mMixes, true); int status = mAudioSystem.registerPolicyMixes(mMixes, true); Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); return status; return status; } } Loading Loading @@ -9039,7 +9039,7 @@ public class AudioService extends IAudioService.Stub @AudioSystem.AudioSystemError private int removeUidDeviceAffinitiesFromSystem(int uid) { @AudioSystem.AudioSystemError private int removeUidDeviceAffinitiesFromSystem(int uid) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { try { return AudioSystem.removeUidDeviceAffinities(uid); return mAudioSystem.removeUidDeviceAffinities(uid); } finally { } finally { Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); } } Loading @@ -9049,7 +9049,7 @@ public class AudioService extends IAudioService.Stub AudioDeviceArray deviceArray) { AudioDeviceArray deviceArray) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { try { return AudioSystem.setUidDeviceAffinities(uid, deviceArray.mDeviceTypes, return mAudioSystem.setUidDeviceAffinities(uid, deviceArray.mDeviceTypes, deviceArray.mDeviceAddresses); deviceArray.mDeviceAddresses); } finally { } finally { Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); Loading Loading @@ -9091,7 +9091,7 @@ public class AudioService extends IAudioService.Stub @UserIdInt int userId) { @UserIdInt int userId) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { try { return AudioSystem.removeUserIdDeviceAffinities(userId); return mAudioSystem.removeUserIdDeviceAffinities(userId); } finally { } finally { Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); } } Loading @@ -9101,7 +9101,7 @@ public class AudioService extends IAudioService.Stub @UserIdInt int userId, AudioDeviceArray deviceArray) { @UserIdInt int userId, AudioDeviceArray deviceArray) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { try { return AudioSystem.setUserIdDeviceAffinities(userId, deviceArray.mDeviceTypes, return mAudioSystem.setUserIdDeviceAffinities(userId, deviceArray.mDeviceTypes, deviceArray.mDeviceAddresses); deviceArray.mDeviceAddresses); } finally { } finally { Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); Loading services/core/java/com/android/server/audio/AudioSystemAdapter.java +122 −0 Original line number Original line Diff line number Diff line Loading @@ -17,9 +17,12 @@ package com.android.server.audio; package com.android.server.audio; import android.annotation.NonNull; import android.annotation.NonNull; import android.media.AudioAttributes; import android.media.AudioDeviceAttributes; import android.media.AudioDeviceAttributes; import android.media.AudioSystem; import android.media.AudioSystem; import android.media.audiopolicy.AudioMix; import java.util.ArrayList; import java.util.List; import java.util.List; /** /** Loading @@ -39,6 +42,25 @@ public class AudioSystemAdapter { return new AudioSystemAdapter(); return new AudioSystemAdapter(); } } /** * Same as {@link AudioSystem#getDevicesForStream(int)} * @param stream a valid stream type * @return a mask of device types */ public int getDevicesForStream(int stream) { return AudioSystem.getDevicesForStream(stream); } /** * Same as {@link AudioSystem#getDevicesForAttributes(AudioAttributes)} * @param attributes the attributes for which the routing is queried * @return the devices that the stream with the given attributes would be routed to */ public @NonNull ArrayList<AudioDeviceAttributes> getDevicesForAttributes( @NonNull AudioAttributes attributes) { return AudioSystem.getDevicesForAttributes(attributes); } /** /** * Same as {@link AudioSystem#setDeviceConnectionState(int, int, String, String, int)} * Same as {@link AudioSystem#setDeviceConnectionState(int, int, String, String, int)} * @param device * @param device Loading Loading @@ -178,4 +200,104 @@ public class AudioSystemAdapter { public boolean isStreamActive(int stream, int inPastMs) { public boolean isStreamActive(int stream, int inPastMs) { return AudioSystem.isStreamActive(stream, inPastMs); return AudioSystem.isStreamActive(stream, inPastMs); } } /** * Same as {@link AudioSystem#isStreamActiveRemotely(int, int)} * @param stream * @param inPastMs * @return */ public boolean isStreamActiveRemotely(int stream, int inPastMs) { return AudioSystem.isStreamActiveRemotely(stream, inPastMs); } /** * Same as {@link AudioSystem#setPhoneState(int, int)} * @param state * @param uid * @return */ public int setPhoneState(int state, int uid) { return AudioSystem.setPhoneState(state, uid); } /** * Same as {@link AudioSystem#setAllowedCapturePolicy(int, int)} * @param uid * @param flags * @return */ public int setAllowedCapturePolicy(int uid, int flags) { return AudioSystem.setAllowedCapturePolicy(uid, flags); } /** * Same as {@link AudioSystem#setForceUse(int, int)} * @param usage * @param config * @return */ public int setForceUse(int usage, int config) { return AudioSystem.setForceUse(usage, config); } /** * Same as {@link AudioSystem#getForceUse(int)} * @param usage * @return */ public int getForceUse(int usage) { return AudioSystem.getForceUse(usage); } /** * Same as {@link AudioSystem#registerPolicyMixes(ArrayList, boolean)} * @param mixes * @param register * @return */ public int registerPolicyMixes(ArrayList<AudioMix> mixes, boolean register) { return AudioSystem.registerPolicyMixes(mixes, register); } /** * Same as {@link AudioSystem#setUidDeviceAffinities(int, int[], String[])} * @param uid * @param types * @param addresses * @return */ public int setUidDeviceAffinities(int uid, @NonNull int[] types, @NonNull String[] addresses) { return AudioSystem.setUidDeviceAffinities(uid, types, addresses); } /** * Same as {@link AudioSystem#removeUidDeviceAffinities(int)} * @param uid * @return */ public int removeUidDeviceAffinities(int uid) { return AudioSystem.removeUidDeviceAffinities(uid); } /** * Same as {@link AudioSystem#setUserIdDeviceAffinities(int, int[], String[])} * @param userId * @param types * @param addresses * @return */ public int setUserIdDeviceAffinities(int userId, @NonNull int[] types, @NonNull String[] addresses) { return AudioSystem.setUserIdDeviceAffinities(userId, types, addresses); } /** * Same as {@link AudioSystem#removeUserIdDeviceAffinities(int)} * @param userId * @return */ public int removeUserIdDeviceAffinities(int userId) { return AudioSystem.removeUserIdDeviceAffinities(userId); } } } Loading
services/core/java/com/android/server/audio/AudioService.java +38 −38 Original line number Original line Diff line number Diff line Loading @@ -1078,7 +1078,7 @@ public class AudioService extends IAudioService.Stub // Restore call state // Restore call state synchronized (mDeviceBroker.mSetModeLock) { synchronized (mDeviceBroker.mSetModeLock) { if (AudioSystem.setPhoneState(mMode, getModeOwnerUid()) if (mAudioSystem.setPhoneState(mMode, getModeOwnerUid()) == AudioSystem.AUDIO_STATUS_OK) { == AudioSystem.AUDIO_STATUS_OK) { mModeLogger.log(new AudioEventLogger.StringEvent( mModeLogger.log(new AudioEventLogger.StringEvent( "onAudioServerDied causes setPhoneState(" + AudioSystem.modeToString(mMode) "onAudioServerDied causes setPhoneState(" + AudioSystem.modeToString(mMode) Loading Loading @@ -1165,7 +1165,7 @@ public class AudioService extends IAudioService.Stub HashMap<Integer, Integer> allowedCapturePolicies = HashMap<Integer, Integer> allowedCapturePolicies = mPlaybackMonitor.getAllAllowedCapturePolicies(); mPlaybackMonitor.getAllAllowedCapturePolicies(); for (HashMap.Entry<Integer, Integer> entry : allowedCapturePolicies.entrySet()) { for (HashMap.Entry<Integer, Integer> entry : allowedCapturePolicies.entrySet()) { int result = AudioSystem.setAllowedCapturePolicy( int result = mAudioSystem.setAllowedCapturePolicy( entry.getKey(), entry.getKey(), AudioAttributes.capturePolicyToFlags(entry.getValue(), 0x0)); AudioAttributes.capturePolicyToFlags(entry.getValue(), 0x0)); if (result != AudioSystem.AUDIO_STATUS_OK) { if (result != AudioSystem.AUDIO_STATUS_OK) { Loading Loading @@ -2112,7 +2112,7 @@ public class AudioService extends IAudioService.Stub protected @NonNull ArrayList<AudioDeviceAttributes> getDevicesForAttributesInt( protected @NonNull ArrayList<AudioDeviceAttributes> getDevicesForAttributesInt( @NonNull AudioAttributes attributes) { @NonNull AudioAttributes attributes) { Objects.requireNonNull(attributes); Objects.requireNonNull(attributes); return AudioSystem.getDevicesForAttributes(attributes); return mAudioSystem.getDevicesForAttributes(attributes); } } /** Indicates no special treatment in the handling of the volume adjustement */ /** Indicates no special treatment in the handling of the volume adjustement */ Loading Loading @@ -2219,7 +2219,7 @@ public class AudioService extends IAudioService.Stub || maybeActiveStreamType == AudioSystem.STREAM_NOTIFICATION) { || maybeActiveStreamType == AudioSystem.STREAM_NOTIFICATION) { activeForReal = wasStreamActiveRecently(maybeActiveStreamType, 0); activeForReal = wasStreamActiveRecently(maybeActiveStreamType, 0); } else { } else { activeForReal = AudioSystem.isStreamActive(maybeActiveStreamType, 0); activeForReal = mAudioSystem.isStreamActive(maybeActiveStreamType, 0); } } if (activeForReal || mVolumeControlStream == -1) { if (activeForReal || mVolumeControlStream == -1) { streamType = maybeActiveStreamType; streamType = maybeActiveStreamType; Loading Loading @@ -2916,7 +2916,7 @@ public class AudioService extends IAudioService.Stub int streamType = getHearingAidStreamType(newMode); int streamType = getHearingAidStreamType(newMode); final Set<Integer> deviceTypes = AudioSystem.generateAudioDeviceTypesSet( final Set<Integer> deviceTypes = AudioSystem.generateAudioDeviceTypesSet( AudioSystem.getDevicesForStream(streamType)); mAudioSystem.getDevicesForStream(streamType)); final Set<Integer> absVolumeMultiModeCaseDevices = AudioSystem.intersectionAudioDeviceTypes( final Set<Integer> absVolumeMultiModeCaseDevices = AudioSystem.intersectionAudioDeviceTypes( mAbsVolumeMultiModeCaseDevices, deviceTypes); mAbsVolumeMultiModeCaseDevices, deviceTypes); if (absVolumeMultiModeCaseDevices.isEmpty()) { if (absVolumeMultiModeCaseDevices.isEmpty()) { Loading Loading @@ -4123,7 +4123,7 @@ public class AudioService extends IAudioService.Stub if (actualMode != mMode) { if (actualMode != mMode) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); status = AudioSystem.setPhoneState(actualMode, getModeOwnerUid()); status = mAudioSystem.setPhoneState(actualMode, getModeOwnerUid()); Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); if (status == AudioSystem.AUDIO_STATUS_OK) { if (status == AudioSystem.AUDIO_STATUS_OK) { if (DEBUG_MODE) { Log.v(TAG, " mode successfully set to " + actualMode); } if (DEBUG_MODE) { Log.v(TAG, " mode successfully set to " + actualMode); } Loading Loading @@ -4597,7 +4597,7 @@ public class AudioService extends IAudioService.Stub caller, caller, MUSIC_ACTIVE_POLL_PERIOD_MS); MUSIC_ACTIVE_POLL_PERIOD_MS); int index = mStreamStates[AudioSystem.STREAM_MUSIC].getIndex(device); int index = mStreamStates[AudioSystem.STREAM_MUSIC].getIndex(device); if (AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0) if (mAudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0) && (index > safeMediaVolumeIndex(device))) { && (index > safeMediaVolumeIndex(device))) { // Approximate cumulative active music time // Approximate cumulative active music time mMusicActiveMs += MUSIC_ACTIVE_POLL_PERIOD_MS; mMusicActiveMs += MUSIC_ACTIVE_POLL_PERIOD_MS; Loading Loading @@ -4981,8 +4981,8 @@ public class AudioService extends IAudioService.Stub * in the last "delay_ms" ms. * in the last "delay_ms" ms. */ */ private boolean wasStreamActiveRecently(int stream, int delay_ms) { private boolean wasStreamActiveRecently(int stream, int delay_ms) { return AudioSystem.isStreamActive(stream, delay_ms) return mAudioSystem.isStreamActive(stream, delay_ms) || AudioSystem.isStreamActiveRemotely(stream, delay_ms); || mAudioSystem.isStreamActiveRemotely(stream, delay_ms); } } private int getActiveStreamType(int suggestedStreamType) { private int getActiveStreamType(int suggestedStreamType) { Loading @@ -4994,7 +4994,7 @@ public class AudioService extends IAudioService.Stub switch (mPlatformType) { switch (mPlatformType) { case AudioSystem.PLATFORM_VOICE: case AudioSystem.PLATFORM_VOICE: if (isInCommunication()) { if (isInCommunication()) { if (AudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) if (mAudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) == AudioSystem.FORCE_BT_SCO) { == AudioSystem.FORCE_BT_SCO) { // Log.v(TAG, "getActiveStreamType: Forcing STREAM_BLUETOOTH_SCO..."); // Log.v(TAG, "getActiveStreamType: Forcing STREAM_BLUETOOTH_SCO..."); return AudioSystem.STREAM_BLUETOOTH_SCO; return AudioSystem.STREAM_BLUETOOTH_SCO; Loading Loading @@ -5031,7 +5031,7 @@ public class AudioService extends IAudioService.Stub } } default: default: if (isInCommunication()) { if (isInCommunication()) { if (AudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) if (mAudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) == AudioSystem.FORCE_BT_SCO) { == AudioSystem.FORCE_BT_SCO) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_BLUETOOTH_SCO"); if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_BLUETOOTH_SCO"); return AudioSystem.STREAM_BLUETOOTH_SCO; return AudioSystem.STREAM_BLUETOOTH_SCO; Loading @@ -5039,31 +5039,31 @@ public class AudioService extends IAudioService.Stub if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_VOICE_CALL"); if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_VOICE_CALL"); return AudioSystem.STREAM_VOICE_CALL; return AudioSystem.STREAM_VOICE_CALL; } } } else if (AudioSystem.isStreamActive( } else if (mAudioSystem.isStreamActive( AudioSystem.STREAM_NOTIFICATION, sStreamOverrideDelayMs)) { AudioSystem.STREAM_NOTIFICATION, sStreamOverrideDelayMs)) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_NOTIFICATION"); if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_NOTIFICATION"); return AudioSystem.STREAM_NOTIFICATION; return AudioSystem.STREAM_NOTIFICATION; } else if (AudioSystem.isStreamActive( } else if (mAudioSystem.isStreamActive( AudioSystem.STREAM_RING, sStreamOverrideDelayMs)) { AudioSystem.STREAM_RING, sStreamOverrideDelayMs)) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_RING"); if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_RING"); return AudioSystem.STREAM_RING; return AudioSystem.STREAM_RING; } else if (suggestedStreamType == AudioManager.USE_DEFAULT_STREAM_TYPE) { } else if (suggestedStreamType == AudioManager.USE_DEFAULT_STREAM_TYPE) { if (AudioSystem.isStreamActive( if (mAudioSystem.isStreamActive( AudioSystem.STREAM_NOTIFICATION, sStreamOverrideDelayMs)) { AudioSystem.STREAM_NOTIFICATION, sStreamOverrideDelayMs)) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_NOTIFICATION"); if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_NOTIFICATION"); return AudioSystem.STREAM_NOTIFICATION; return AudioSystem.STREAM_NOTIFICATION; } else if (AudioSystem.isStreamActive( } if (mAudioSystem.isStreamActive( AudioSystem.STREAM_RING, sStreamOverrideDelayMs)) { AudioSystem.STREAM_RING, sStreamOverrideDelayMs)) { if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_RING"); if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Forcing STREAM_RING"); return AudioSystem.STREAM_RING; return AudioSystem.STREAM_RING; } else { } if (DEBUG_VOL) { if (DEBUG_VOL) { Log.v(TAG, "getActiveStreamType: Forcing DEFAULT_VOL_STREAM_NO_PLAYBACK(" Log.v(TAG, "getActiveStreamType: Forcing DEFAULT_VOL_STREAM_NO_PLAYBACK(" + DEFAULT_VOL_STREAM_NO_PLAYBACK + ") b/c default"); + DEFAULT_VOL_STREAM_NO_PLAYBACK + ") b/c default"); } } return DEFAULT_VOL_STREAM_NO_PLAYBACK; return DEFAULT_VOL_STREAM_NO_PLAYBACK; } } } break; break; } } if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Returning suggested type " if (DEBUG_VOL) Log.v(TAG, "getActiveStreamType: Returning suggested type " Loading Loading @@ -5477,7 +5477,7 @@ public class AudioService extends IAudioService.Stub && DEVICE_MEDIA_UNMUTED_ON_PLUG_SET.contains(newDevice) && DEVICE_MEDIA_UNMUTED_ON_PLUG_SET.contains(newDevice) && mStreamStates[AudioSystem.STREAM_MUSIC].mIsMuted && mStreamStates[AudioSystem.STREAM_MUSIC].mIsMuted && mStreamStates[AudioSystem.STREAM_MUSIC].getIndex(newDevice) != 0 && mStreamStates[AudioSystem.STREAM_MUSIC].getIndex(newDevice) != 0 && (newDevice & AudioSystem.getDevicesForStream(AudioSystem.STREAM_MUSIC)) != 0) { && (newDevice & mAudioSystem.getDevicesForStream(AudioSystem.STREAM_MUSIC)) != 0) { if (DEBUG_VOL) { if (DEBUG_VOL) { Log.i(TAG, String.format("onAccessoryPlugMediaUnmute unmuting device=%d [%s]", Log.i(TAG, String.format("onAccessoryPlugMediaUnmute unmuting device=%d [%s]", newDevice, AudioSystem.getOutputDeviceName(newDevice))); newDevice, AudioSystem.getOutputDeviceName(newDevice))); Loading Loading @@ -5945,7 +5945,7 @@ public class AudioService extends IAudioService.Stub if (!mSystemServer.isPrivileged()) { if (!mSystemServer.isPrivileged()) { return AudioSystem.DEVICE_NONE; return AudioSystem.DEVICE_NONE; } } final int devices = AudioSystem.getDevicesForStream(mStreamType); final int devices = mAudioSystem.getDevicesForStream(mStreamType); if (devices == mObservedDevices) { if (devices == mObservedDevices) { return devices; return devices; } } Loading Loading @@ -6670,7 +6670,7 @@ public class AudioService extends IAudioService.Stub .record(); .record(); sForceUseLogger.log( sForceUseLogger.log( new AudioServiceEvents.ForceUseEvent(useCase, config, eventSource)); new AudioServiceEvents.ForceUseEvent(useCase, config, eventSource)); AudioSystem.setForceUse(useCase, config); mAudioSystem.setForceUse(useCase, config); } } break; break; Loading Loading @@ -7993,7 +7993,7 @@ public class AudioService extends IAudioService.Stub } } } } public static class VolumeController { public class VolumeController { private static final String TAG = "VolumeController"; private static final String TAG = "VolumeController"; private IVolumeController mController; private IVolumeController mController; Loading Loading @@ -8033,7 +8033,7 @@ public class AudioService extends IAudioService.Stub if (resolvedStream == DEFAULT_VOL_STREAM_NO_PLAYBACK && mController != null) { if (resolvedStream == DEFAULT_VOL_STREAM_NO_PLAYBACK && mController != null) { // never suppress media vol adjustement during media playback // never suppress media vol adjustement during media playback if (resolvedStream == AudioSystem.STREAM_MUSIC if (resolvedStream == AudioSystem.STREAM_MUSIC && AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, mLongPressTimeout)) && mAudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, mLongPressTimeout)) { { // media is playing, adjust the volume right away // media is playing, adjust the volume right away return false; return false; Loading Loading @@ -8071,7 +8071,7 @@ public class AudioService extends IAudioService.Stub return binder(mController); return binder(mController); } } private static IBinder binder(IVolumeController controller) { private IBinder binder(IVolumeController controller) { return controller == null ? null : controller.asBinder(); return controller == null ? null : controller.asBinder(); } } Loading Loading @@ -8800,7 +8800,7 @@ public class AudioService extends IAudioService.Stub int flags = AudioAttributes.capturePolicyToFlags(capturePolicy, 0x0); int flags = AudioAttributes.capturePolicyToFlags(capturePolicy, 0x0); final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); synchronized (mPlaybackMonitor) { synchronized (mPlaybackMonitor) { int result = AudioSystem.setAllowedCapturePolicy(callingUid, flags); int result = mAudioSystem.setAllowedCapturePolicy(callingUid, flags); if (result == AudioSystem.AUDIO_STATUS_OK) { if (result == AudioSystem.AUDIO_STATUS_OK) { mPlaybackMonitor.setAllowedCapturePolicy(callingUid, capturePolicy); mPlaybackMonitor.setAllowedCapturePolicy(callingUid, capturePolicy); } } Loading Loading @@ -8943,7 +8943,7 @@ public class AudioService extends IAudioService.Stub } } } } final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); AudioSystem.registerPolicyMixes(mMixes, false); mAudioSystem.registerPolicyMixes(mMixes, false); Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); synchronized (mAudioPolicies) { synchronized (mAudioPolicies) { mAudioPolicies.remove(mPolicyCallback.asBinder()); mAudioPolicies.remove(mPolicyCallback.asBinder()); Loading Loading @@ -8986,24 +8986,24 @@ public class AudioService extends IAudioService.Stub int addMixes(@NonNull ArrayList<AudioMix> mixes) { int addMixes(@NonNull ArrayList<AudioMix> mixes) { // TODO optimize to not have to unregister the mixes already in place // TODO optimize to not have to unregister the mixes already in place synchronized (mMixes) { synchronized (mMixes) { AudioSystem.registerPolicyMixes(mMixes, false); mAudioSystem.registerPolicyMixes(mMixes, false); this.add(mixes); this.add(mixes); return AudioSystem.registerPolicyMixes(mMixes, true); return mAudioSystem.registerPolicyMixes(mMixes, true); } } } } int removeMixes(@NonNull ArrayList<AudioMix> mixes) { int removeMixes(@NonNull ArrayList<AudioMix> mixes) { // TODO optimize to not have to unregister the mixes already in place // TODO optimize to not have to unregister the mixes already in place synchronized (mMixes) { synchronized (mMixes) { AudioSystem.registerPolicyMixes(mMixes, false); mAudioSystem.registerPolicyMixes(mMixes, false); this.remove(mixes); this.remove(mixes); return AudioSystem.registerPolicyMixes(mMixes, true); return mAudioSystem.registerPolicyMixes(mMixes, true); } } } } @AudioSystem.AudioSystemError int connectMixes() { @AudioSystem.AudioSystemError int connectMixes() { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); int status = AudioSystem.registerPolicyMixes(mMixes, true); int status = mAudioSystem.registerPolicyMixes(mMixes, true); Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); return status; return status; } } Loading Loading @@ -9039,7 +9039,7 @@ public class AudioService extends IAudioService.Stub @AudioSystem.AudioSystemError private int removeUidDeviceAffinitiesFromSystem(int uid) { @AudioSystem.AudioSystemError private int removeUidDeviceAffinitiesFromSystem(int uid) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { try { return AudioSystem.removeUidDeviceAffinities(uid); return mAudioSystem.removeUidDeviceAffinities(uid); } finally { } finally { Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); } } Loading @@ -9049,7 +9049,7 @@ public class AudioService extends IAudioService.Stub AudioDeviceArray deviceArray) { AudioDeviceArray deviceArray) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { try { return AudioSystem.setUidDeviceAffinities(uid, deviceArray.mDeviceTypes, return mAudioSystem.setUidDeviceAffinities(uid, deviceArray.mDeviceTypes, deviceArray.mDeviceAddresses); deviceArray.mDeviceAddresses); } finally { } finally { Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); Loading Loading @@ -9091,7 +9091,7 @@ public class AudioService extends IAudioService.Stub @UserIdInt int userId) { @UserIdInt int userId) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { try { return AudioSystem.removeUserIdDeviceAffinities(userId); return mAudioSystem.removeUserIdDeviceAffinities(userId); } finally { } finally { Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); } } Loading @@ -9101,7 +9101,7 @@ public class AudioService extends IAudioService.Stub @UserIdInt int userId, AudioDeviceArray deviceArray) { @UserIdInt int userId, AudioDeviceArray deviceArray) { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { try { return AudioSystem.setUserIdDeviceAffinities(userId, deviceArray.mDeviceTypes, return mAudioSystem.setUserIdDeviceAffinities(userId, deviceArray.mDeviceTypes, deviceArray.mDeviceAddresses); deviceArray.mDeviceAddresses); } finally { } finally { Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); Loading
services/core/java/com/android/server/audio/AudioSystemAdapter.java +122 −0 Original line number Original line Diff line number Diff line Loading @@ -17,9 +17,12 @@ package com.android.server.audio; package com.android.server.audio; import android.annotation.NonNull; import android.annotation.NonNull; import android.media.AudioAttributes; import android.media.AudioDeviceAttributes; import android.media.AudioDeviceAttributes; import android.media.AudioSystem; import android.media.AudioSystem; import android.media.audiopolicy.AudioMix; import java.util.ArrayList; import java.util.List; import java.util.List; /** /** Loading @@ -39,6 +42,25 @@ public class AudioSystemAdapter { return new AudioSystemAdapter(); return new AudioSystemAdapter(); } } /** * Same as {@link AudioSystem#getDevicesForStream(int)} * @param stream a valid stream type * @return a mask of device types */ public int getDevicesForStream(int stream) { return AudioSystem.getDevicesForStream(stream); } /** * Same as {@link AudioSystem#getDevicesForAttributes(AudioAttributes)} * @param attributes the attributes for which the routing is queried * @return the devices that the stream with the given attributes would be routed to */ public @NonNull ArrayList<AudioDeviceAttributes> getDevicesForAttributes( @NonNull AudioAttributes attributes) { return AudioSystem.getDevicesForAttributes(attributes); } /** /** * Same as {@link AudioSystem#setDeviceConnectionState(int, int, String, String, int)} * Same as {@link AudioSystem#setDeviceConnectionState(int, int, String, String, int)} * @param device * @param device Loading Loading @@ -178,4 +200,104 @@ public class AudioSystemAdapter { public boolean isStreamActive(int stream, int inPastMs) { public boolean isStreamActive(int stream, int inPastMs) { return AudioSystem.isStreamActive(stream, inPastMs); return AudioSystem.isStreamActive(stream, inPastMs); } } /** * Same as {@link AudioSystem#isStreamActiveRemotely(int, int)} * @param stream * @param inPastMs * @return */ public boolean isStreamActiveRemotely(int stream, int inPastMs) { return AudioSystem.isStreamActiveRemotely(stream, inPastMs); } /** * Same as {@link AudioSystem#setPhoneState(int, int)} * @param state * @param uid * @return */ public int setPhoneState(int state, int uid) { return AudioSystem.setPhoneState(state, uid); } /** * Same as {@link AudioSystem#setAllowedCapturePolicy(int, int)} * @param uid * @param flags * @return */ public int setAllowedCapturePolicy(int uid, int flags) { return AudioSystem.setAllowedCapturePolicy(uid, flags); } /** * Same as {@link AudioSystem#setForceUse(int, int)} * @param usage * @param config * @return */ public int setForceUse(int usage, int config) { return AudioSystem.setForceUse(usage, config); } /** * Same as {@link AudioSystem#getForceUse(int)} * @param usage * @return */ public int getForceUse(int usage) { return AudioSystem.getForceUse(usage); } /** * Same as {@link AudioSystem#registerPolicyMixes(ArrayList, boolean)} * @param mixes * @param register * @return */ public int registerPolicyMixes(ArrayList<AudioMix> mixes, boolean register) { return AudioSystem.registerPolicyMixes(mixes, register); } /** * Same as {@link AudioSystem#setUidDeviceAffinities(int, int[], String[])} * @param uid * @param types * @param addresses * @return */ public int setUidDeviceAffinities(int uid, @NonNull int[] types, @NonNull String[] addresses) { return AudioSystem.setUidDeviceAffinities(uid, types, addresses); } /** * Same as {@link AudioSystem#removeUidDeviceAffinities(int)} * @param uid * @return */ public int removeUidDeviceAffinities(int uid) { return AudioSystem.removeUidDeviceAffinities(uid); } /** * Same as {@link AudioSystem#setUserIdDeviceAffinities(int, int[], String[])} * @param userId * @param types * @param addresses * @return */ public int setUserIdDeviceAffinities(int userId, @NonNull int[] types, @NonNull String[] addresses) { return AudioSystem.setUserIdDeviceAffinities(userId, types, addresses); } /** * Same as {@link AudioSystem#removeUserIdDeviceAffinities(int)} * @param userId * @return */ public int removeUserIdDeviceAffinities(int userId) { return AudioSystem.removeUserIdDeviceAffinities(userId); } } }