frameworks/base/media/java/android/media/AudioService.java
1190private int getActiveStreamType(int suggestedStreamType) {
1191boolean isOffhook = false;
1192try {
1193ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
1194if (phone != null) isOffhook = phone.isOffhook();
1195} catch (RemoteException e) {
1196Log.w(TAG, "Couldn't connect to phone service", e);
1197}
1198
1199if (AudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) == AudioSystem.FORCE_BT_SCO) {
1200// Log.v(TAG, "getActiveStreamType: Forcing STREAM_BLUETOOTH_SCO...");
1201return AudioSystem.STREAM_BLUETOOTH_SCO;
1202} else if (isOffhook || AudioSystem.isStreamActive(AudioSystem.STREAM_VOICE_CALL)) {
1203// Log.v(TAG, "getActiveStreamType: Forcing STREAM_VOICE_CALL...");
1204return AudioSystem.STREAM_VOICE_CALL;
1205} else if (AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC)) {
1206// Log.v(TAG, "getActiveStreamType: Forcing STREAM_MUSIC...");
1207return AudioSystem.STREAM_MUSIC;
1208} else if (suggestedStreamType == AudioManager.USE_DEFAULT_STREAM_TYPE) {
1209// Log.v(TAG, "getActiveStreamType: Forcing STREAM_RING...");
1210return AudioSystem.STREAM_MUSIC; //STREAM_RING;
1211} else {
1212// Log.v(TAG, "getActiveStreamType: Returning suggested type " + suggestedStreamType);
1213return suggestedStreamType;
1214}
1215}