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

来源:互联网 发布:软交换网络各节点功能 编辑:程序博客网 时间:2024/04/29 19:56
[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
原创粉丝点击