您的位置:首页 > 移动开发 > Android开发

Android 音量调节

2011-04-28 00:00 316 查看
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     }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: