FAQ11272][Audio App]微信语音通话(听筒模式),音量侧键不能调音量
2016-06-20 14:30
483 查看
[DESCRIPTION]
微信语音通话(听筒模式),音量侧键不能调音量
[SOLUTION]
google参考机也是如此,不过可以按如下修改:
alps\frameworks\base\media\java\android\media\AudioService.java
1.private boolean isInCommunication() {
boolean isOffhook = false;
if (mVoiceCapable) {
try {
ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
if (phone != null) isOffhook = phone.isOffhook();
} catch (RemoteException e) {
Log.w(TAG, "Couldn't connect to phone service", e);
}
}
// Add for wechat start
return (isOffhook || getMode() == AudioManager.MODE_IN_COMMUNICATION || getMode() == AudioManager.MODE_IN_CALL);
// Add for wechat end
}
2.public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags) {
if (DEBUG_VOL) Log.d(TAG, "adjustSuggestedStreamVolume() stream="+suggestedStreamType);
int streamType;
if (mVolumeControlStream != -1) {
streamType = mVolumeControlStream;
// Add for wechat start
if(streamType== AudioSystem.STREAM_MUSIC && AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0) && getMode() == AudioManager.MODE_IN_CALL && !AudioSystem.isStreamActive(AudioSystem.STREAM_VOICE_CALL, 0))
streamType = getActiveStreamType(suggestedStreamType);
// Add for wechat end
} else {
streamType = getActiveStreamType(suggestedStreamType);
}
// Play sounds on STREAM_RING only and if lock screen is not on.
if ((streamType != STREAM_REMOTE_MUSIC) &&
(flags & AudioManager.FLAG_PLAY_SOUND) != 0 &&
((mStreamVolumeAlias[streamType] != AudioSystem.STREAM_RING)
|| (mKeyguardManager != null && mKeyguardManager.isKeyguardLocked()))) {
flags &= ~AudioManager.FLAG_PLAY_SOUND;
}
if (streamType == STREAM_REMOTE_MUSIC) {
// don't play sounds for remote
flags &= ~(AudioManager.FLAG_PLAY_SOUND|AudioManager.FLAG_FIXED_VOLUME);
//if (DEBUG_VOL) Log.i(TAG, "Need to adjust remote volume: calling adjustRemoteVolume()");
adjustRemoteVolume(AudioSystem.STREAM_MUSIC, direction, flags);
} else {
adjustStreamVolume(streamType, direction, flags);
}
}
3.public void adjustStreamVolume(int streamType, int direction, int flags, String callingPackage) {
if (mUseFixedVolume) {
return;
}
if (DEBUG_VOL) Log.d(TAG, "adjustStreamVolume() stream="+streamType+", dir="+direction);
ensureValidDirection(direction);
ensureValidStreamType(streamType);
// Add for wechat start
if (streamType == AudioSystem.STREAM_MUSIC
&& AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0)
&& getMode() == AudioManager.MODE_IN_CALL
&& !AudioSystem.isStreamActive(AudioSystem.STREAM_VOICE_CALL, 0)) {
streamType = getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE);
}
// Add for wechat end
微信语音通话(听筒模式),音量侧键不能调音量
[SOLUTION]
google参考机也是如此,不过可以按如下修改:
alps\frameworks\base\media\java\android\media\AudioService.java
1.private boolean isInCommunication() {
boolean isOffhook = false;
if (mVoiceCapable) {
try {
ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
if (phone != null) isOffhook = phone.isOffhook();
} catch (RemoteException e) {
Log.w(TAG, "Couldn't connect to phone service", e);
}
}
// Add for wechat start
return (isOffhook || getMode() == AudioManager.MODE_IN_COMMUNICATION || getMode() == AudioManager.MODE_IN_CALL);
// Add for wechat end
}
2.public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags) {
if (DEBUG_VOL) Log.d(TAG, "adjustSuggestedStreamVolume() stream="+suggestedStreamType);
int streamType;
if (mVolumeControlStream != -1) {
streamType = mVolumeControlStream;
// Add for wechat start
if(streamType== AudioSystem.STREAM_MUSIC && AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0) && getMode() == AudioManager.MODE_IN_CALL && !AudioSystem.isStreamActive(AudioSystem.STREAM_VOICE_CALL, 0))
streamType = getActiveStreamType(suggestedStreamType);
// Add for wechat end
} else {
streamType = getActiveStreamType(suggestedStreamType);
}
// Play sounds on STREAM_RING only and if lock screen is not on.
if ((streamType != STREAM_REMOTE_MUSIC) &&
(flags & AudioManager.FLAG_PLAY_SOUND) != 0 &&
((mStreamVolumeAlias[streamType] != AudioSystem.STREAM_RING)
|| (mKeyguardManager != null && mKeyguardManager.isKeyguardLocked()))) {
flags &= ~AudioManager.FLAG_PLAY_SOUND;
}
if (streamType == STREAM_REMOTE_MUSIC) {
// don't play sounds for remote
flags &= ~(AudioManager.FLAG_PLAY_SOUND|AudioManager.FLAG_FIXED_VOLUME);
//if (DEBUG_VOL) Log.i(TAG, "Need to adjust remote volume: calling adjustRemoteVolume()");
adjustRemoteVolume(AudioSystem.STREAM_MUSIC, direction, flags);
} else {
adjustStreamVolume(streamType, direction, flags);
}
}
3.public void adjustStreamVolume(int streamType, int direction, int flags, String callingPackage) {
if (mUseFixedVolume) {
return;
}
if (DEBUG_VOL) Log.d(TAG, "adjustStreamVolume() stream="+streamType+", dir="+direction);
ensureValidDirection(direction);
ensureValidStreamType(streamType);
// Add for wechat start
if (streamType == AudioSystem.STREAM_MUSIC
&& AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0)
&& getMode() == AudioManager.MODE_IN_CALL
&& !AudioSystem.isStreamActive(AudioSystem.STREAM_VOICE_CALL, 0)) {
streamType = getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE);
}
// Add for wechat end
相关文章推荐
- Android使用Application总结
- Android学习笔记七之ContentProvider
- virtualenv and virtualenvwrapper
- 如何优雅的插入广告-iOS篇
- px、pt、ppi、dpi、dp、sp之间的关系
- 我的Android进阶之旅---Activity不同启动模式下应用程序栈的变化
- Java Jvm、Android Dalvik和Android Art(一)——Android之路
- Android TypedArray使用方法
- IOS进阶之Social.framework一键分享文字图片到新浪微博,facebook,twitter 还有保存打印等
- 1.1、Android Studio创建一个项目
- 1.1、Android Studio创建一个项目
- 使用android自带的DownloadManager来实现版本更新
- Android SQLiteDatabase帮助类SQLiteOpenHelper的使用
- 8个实用排版技巧,让微信颜值美出新高度!
- android 各类常用框架大全(不全)
- 【转】iOS 宏(define)与常量(const)的正确使用-- 不错
- android中The connection to adb is down,问题和解决
- android material design之CollapsingToolbarLayout(五)
- iOS 调试与发布模式自定义显示宏
- IOS 进阶Accounts.framework和Social.framework