[RK3288][Android6.0] 耳机插拔处理两种方式

Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92

系统对耳机插拔处理的方式有两种,一种是UEvent直接上报,另一种是通过Input模块来处理。


对应配置

frameworks\base\core\res\res\values\Config.xml


    
    <bool name="config_useDevInputEventForAudioJack">falsebool>

注释说明得很清楚了,true表示使用input模块处理,false表示使用uevent框架。


实现:

WiredAccessoryManager.java

读取:

mUseDevInputEventForAudioJack =
                context.getResources().getBoolean(R.bool.config_useDevInputEventForAudioJack);

判断:

private void onSystemReady() {
    if (mUseDevInputEventForAudioJack) {
        int switchValues = 0;
        if (mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_HEADPHONE_INSERT) == 1) {
            switchValues |= SW_HEADPHONE_INSERT_BIT;
        }
        if (mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_MICROPHONE_INSERT) == 1) {
            switchValues |= SW_MICROPHONE_INSERT_BIT;
        }
        if (mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_LINEOUT_INSERT) == 1) {
            switchValues |= SW_LINEOUT_INSERT_BIT;
        }
        notifyWiredAccessoryChanged(0, switchValues,
                SW_HEADPHONE_INSERT_BIT | SW_MICROPHONE_INSERT_BIT | SW_LINEOUT_INSERT_BIT);
    }
}
private List makeObservedUEventList() {
    // Monitor h2w
    if (!mUseDevInputEventForAudioJack) {
        uei = new UEventInfo(NAME_H2W, BIT_HEADSET, BIT_HEADSET_NO_MIC, BIT_LINEOUT);
        if (uei.checkSwitchExists()) {
            retVal.add(uei);
        } else {
            Slog.w(TAG, "This kernel does not have wired headset support");
        }
    }
}

你可能感兴趣的:(子类__Audio)