adb shell settings 控制安卓系統設定

來源:互聯網
上載者:User

標籤: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 控制安卓系統設定(轉)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.