標籤:href int oem input col blank one oba efault
Android4.2的源碼android-17\com\android\commands目錄下較之前的版本多了一個settings命令,查看其中的SettingsCmd.java檔案,末尾有命令的協助資訊:
1 private static void printUsage() {2 System.err.println("usage: settings [--user NUM] get namespace key");3 System.err.println(" settings [--user NUM] put namespace key value");4 System.err.println("\n‘namespace‘ is one of {system, secure, global}, case-insensitive");5 System.err.println("If ‘--user NUM‘ is not given, the operations are performed on the owner user.");6 }
選項中的key為什麼值,很難從協助資訊中看出,從代碼中查看該key值是在android.provider.Settings中定義了。
http://developer.android.com/reference/android/provider/Settings.System.html
該命令可以很方便的更改系統設定中的參數(如修改系統預設IME),給出幾個使用該命令的例子:
1 #擷取系統預設IME 2 #預設搜狗IME 3 C:\Users\Administrator>adb shell settings get secure default_input_method 4 com.sohu.inputmethod.sogouoem/.SogouIME 5 6 #預設為Appium使用中文輸入時安裝的IME 7 C:\Users\Administrator>adb shell settings get secure default_input_method 8 io.appium.android.ime/.UnicodeIME 9 10 #put命令更改預設IME(將io.appium.android.ime/.UnicodeIME改為com.sohu.inputmethod.sogouoem/.SogouIME)11 C:\Users\Administrator>adb shell settings put secure default_input_method com.sohu.inputmethod.sogouoem/.SogouIME
1 #擷取亮度是否為自動擷取2 C:\Users\Administrator>adb shell settings get system screen_brightness_mode3 14 #擷取當前亮度值5 C:\Users\Administrator>adb shell settings get system screen_brightness6 307 #更改亮度值(亮度值在0—255之間)8 C:\Users\Administrator>adb shell settings put system screen_brightness 150
1 #擷取螢幕休眠時間2 C:\Users\Administrator>adb shell settings get system screen_off_timeout3 150004 #更改休眠時間,10分鐘5 C:\Users\Administrator>adb shell settings put system screen_off_timeout 600000
1 #擷取日期時間選項中通過網路擷取時間的狀態,1為允許、0為不允許2 C:\Users\Administrator>adb shell settings get global auto_time3 14 #更改該狀態,從1改為05 C:\Users\Administrator>adb shell settings put global auto_time 0
以及擷取、修改wifi狀態(wifi_on)、飛航模式(airlpane_mode_on)等,這裡也是appium中getNetworkConnection獲得裝置網路狀態的方法。
adb shell settings 控制安卓系統設定(轉)