Merge "setWiredDeviceConnectionState requires MODIFY_AUDIO_ROUTING"

This commit is contained in:
Treehugger Robot
2020-03-25 17:53:56 +00:00
committed by Gerrit Code Review
2 changed files with 2 additions and 0 deletions

View File

@@ -4213,6 +4213,7 @@ public class AudioManager {
* {@hide} * {@hide}
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage
@RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
public void setWiredDeviceConnectionState(int type, int state, String address, String name) { public void setWiredDeviceConnectionState(int type, int state, String address, String name) {
final IAudioService service = getService(); final IAudioService service = getService();
try { try {

View File

@@ -4318,6 +4318,7 @@ public class AudioService extends IAudioService.Stub
public void setWiredDeviceConnectionState(int type, public void setWiredDeviceConnectionState(int type,
@ConnectionState int state, String address, String name, @ConnectionState int state, String address, String name,
String caller) { String caller) {
enforceModifyAudioRoutingPermission();
if (state != CONNECTION_STATE_CONNECTED if (state != CONNECTION_STATE_CONNECTED
&& state != CONNECTION_STATE_DISCONNECTED) { && state != CONNECTION_STATE_DISCONNECTED) {
throw new IllegalArgumentException("Invalid state " + state); throw new IllegalArgumentException("Invalid state " + state);