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