Adds support for USB audio devices in AppRTCMobile on Android.
This change extends the definition of wired headset to also include USB devices. The effect is that audio will now be routed to USB audio devices when used in combination with AppRTCMobile. BUG=webrtc:7931 Review-Url: https://codereview.webrtc.org/2971613003 Cr-Commit-Position: refs/heads/master@{#18889}
This commit is contained in:
@ -18,7 +18,9 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.media.AudioDeviceInfo;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
@ -437,7 +439,25 @@ public class AppRTCAudioManager {
|
||||
*/
|
||||
@Deprecated
|
||||
private boolean hasWiredHeadset() {
|
||||
return audioManager.isWiredHeadsetOn();
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
return audioManager.isWiredHeadsetOn();
|
||||
} else {
|
||||
final AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_ALL);
|
||||
for (AudioDeviceInfo device : devices) {
|
||||
final int type = device.getType();
|
||||
if (type == AudioDeviceInfo.TYPE_WIRED_HEADSET) {
|
||||
Log.d(TAG, "hasWiredHeadset: found wired headset");
|
||||
return true;
|
||||
} else if (type == AudioDeviceInfo.TYPE_USB_DEVICE) {
|
||||
Log.d(TAG, "hasWiredHeadset: found USB audio device");
|
||||
return true;
|
||||
} else if (type == AudioDeviceInfo.TYPE_USB_HEADSET) {
|
||||
Log.d(TAG, "hasWiredHeadset: found USB headset");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user