FAQ11272][Audio App]微信语音通话(听筒模式),音量侧键不能调音量

[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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值