android 物理鍵盤 關鍵因素

來源:互聯網
上載者:User

參考PhoneWindowManager.java的adjustConfigurationLw()方法,可以找出以下關鍵因素:

config_lidKeyboardAccessibility:在frameworks/base/core/res/res/values/config.xml中定義,含義如下:

 Indicate whether the lid state impacts the accessibility of the physical keyboard. 

0 means it doesn't,

1 means it is accessible when the lid is open,

2 means it is accessible when the lid is closed.

The default is 1.

意為物理鍵盤是否受滑蓋影響,0表示不受滑蓋影響,1表示當滑蓋開啟時物理鍵盤可用,2表示滑蓋關閉時物理鍵盤可用。

 

另外PhoneWindowManager.java還有個常量也對物理鍵盤的狀態有影響:

// Debugging: set this to have the system act like there is no hard keyboard.
static final boolean KEYBOARD_ALWAYS_HIDDEN = false;

 

InputMethodService.java: 判斷是否顯示軟鍵盤的代碼:

onShowInputRequested() {

        if (!onEvaluateInputViewShown()) {
            return false;
        }
       ......................

}

    public boolean onEvaluateInputViewShown() {
        Configuration config = getResources().getConfiguration();
        return config.keyboard == Configuration.KEYBOARD_NOKEYS
                || config.hardKeyboardHidden == Configuration.KEYBOARDHIDDEN_YES;
    }

其中兩項config.hardKeyboardHidden就是framworks中config.xml的config_lidKeyboardAccessibility取值

 

 

物理鍵盤對應過程:
手機/system/usr/keylayout/*.kl :核心將keyCode映射成有含義的字串
KeycodeLabels.h : framework 將字串映射成keyEvent的keyCode
frameworks/.../res/values/attrs.xml

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.