Android 音量调节
frameworks/base/media/java/android/media/AudioService.java
011190 private int getActiveStreamType(int suggestedStreamType) {
021191 boolean isOffhook = false;
031192 try {
041193 ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
051194 if (phone != null) isOffhook = phone.isOffhook();
061195 } catch (RemoteException e) {
071196 Log.w(TAG, "Couldn't connect to phone service", e);
081197 }
091198
101199 if(AudioSystem.getForceUse(AudioSystem.FOR_COMMUNICATION) == AudioSystem.FORCE_BT_SCO) {
111200 // Log.v(TAG, "getActiveStreamType: Forcing STREAM_BLUETOOTH_SCO...");
121201 return AudioSystem.STREAM_BLUETOOTH_SCO;
131202 } else if(isOffhook || AudioSystem.isStreamActive(AudioSystem.STREAM_VOICE_CALL)) {
141203 // Log.v(TAG, "getActiveStreamType: Forcing STREAM_VOICE_CALL...");
151204 return AudioSystem.STREAM_VOICE_CALL;
161205 } else if (AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC)) {
171206 // Log.v(TAG, "getActiveStreamType: Forcing STREAM_MUSIC...");
181207 return AudioSystem.STREAM_MUSIC;
191208 } else if(suggestedStreamType == AudioManager.USE_DEFAULT_STREAM_TYPE) {
201209 // Log.v(TAG, "getActiveStreamType: Forcing STREAM_RING...");
211210 return AudioSystem.STREAM_MUSIC; //STREAM_RING;
221211 } else {
231212 // Log.v(TAG, "getActiveStreamType: Returning suggested type " + suggestedStreamType);
241213 return suggestedStreamType;
251214 }
261215 }