adb shell settings
原文链接: http://www.cnblogs.com/rosepotato/p/4280838.html Android4.2的源码android-17comandroidcommands目录下较之前的版本多了一个settings命令,查看其中的SettingsCmd.java文件,末尾有命令的帮助信息: private static void printUsage() { System.err.println("usage: settings [--user NUM] get namespace key"); System.err.println(" settings [--user NUM] put namespace key value"); System.err.println("n'namespace' is one of {system,secure,global},case-insensitive"); System.err.println("If '--user NUM' is not given,the operations are performed on the owner user."); } 选项中的key为什么值,很难从帮助信息中看出,从代码中查看该key值是在android.provider.Settings中定义了。 http://developer.android.com/reference/android/provider/Settings.System.html 该命令可以很方便的更改系统设置中的参数(如修改系统默认输入法),给出几个使用该命令的例子: 获取系统默认输入法 #默认搜狗输入法C:UsersAdministrator>adb shell settings get secure default_input_method com.sohu.inputmethod.sogouoem/.SogouIME 默认为Appium使用中文输入时安装的输入法C:UsersAdministrator>adb shell settings get secure default_input_method io.appium.android.ime/.UnicodeIME put命令更改默认输入法(将io.appium.android.ime/.UnicodeIME改为com.sohu.inputmethod.sogouoem/.SogouIME)C:UsersAdministrator>adb shell settings put secure default_input_method com.sohu.inputmethod.sogouoem/.SogouIME 获取亮度是否为自动获取C:UsersAdministrator>adb shell settings get system screen_brightness_mode 1 获取当前亮度值C:UsersAdministrator>adb shell settings get system screen_brightness 30 更改亮度值(亮度值在0—255之间)C:UsersAdministrator>adb shell settings put system screen_brightness 150 获取屏幕休眠时间C:UsersAdministrator>adb shell settings get system screen_off_timeout 15000 更改休眠时间,10分钟C:UsersAdministrator>adb shell settings put system screen_off_timeout 600000 获取日期时间选项中通过网络获取时间的状态,1为允许、0为不允许C:UsersAdministrator>adb shell settings get global auto_time 1 更改该状态,从1改为0C:UsersAdministrator>adb shell settings put global auto_time 0 以及获取、修改wifi状态(wifi_on)、飞行模式(airlpane_mode_on)等,这里也是appium中getNetworkConnection获得设备网络状态的方法。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |