Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(834)

Unified Diff: webrtc/examples/androidapp/src/org/appspot/apprtc/AppRTCAudioManager.java

Issue 2971613003: Adds support for USB audio devices in AppRTCMobile on Android (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/examples/androidapp/src/org/appspot/apprtc/AppRTCAudioManager.java
diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/AppRTCAudioManager.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/AppRTCAudioManager.java
index a57e84f8ca0aa81ed8ba6596ec3831e16667044d..992d9188ba9881dd7492ea675957a1deb5c87421 100644
--- a/webrtc/examples/androidapp/src/org/appspot/apprtc/AppRTCAudioManager.java
+++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/AppRTCAudioManager.java
@@ -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;
+ }
}
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698