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

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