微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

adb shell settings

原文链接http://www.cnblogs.com/rosepotato/p/4280838.html

Android4.2的源码android-17\com\android\commands目录下较之前的版本多了一个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:\Users\Administrator>adb shell settings get secure default_input_method

com.sohu.inputmethod.sogouoem/.sogouIME

认为Appium使用中文输入时安装的输入法

C:\Users\Administrator>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:\Users\Administrator>adb shell settings put secure default_input_method com.sohu.inputmethod.sogouoem/.sogouIME

获取亮度是否为自动获取

C:\Users\Administrator>adb shell settings get system screen_brightness_mode

1

获取当前亮度值

C:\Users\Administrator>adb shell settings get system screen_brightness

30

更改亮度值(亮度值在0—255之间)

C:\Users\Administrator>adb shell settings put system screen_brightness 150

获取屏幕休眠时间

C:\Users\Administrator>adb shell settings get system screen_off_timeout

15000

更改休眠时间,10分钟

C:\Users\Administrator>adb shell settings put system screen_off_timeout 600000

获取日期时间选项中通过网络获取间的状态,1为允许、0为不允许

C:\Users\Administrator>adb shell settings get global auto_time

1

更改该状态,从1改为0

C:\Users\Administrator>adb shell settings put global auto_time 0

以及获取修改wifi状态(wifi_on)、飞行模式(airlpane_mode_on)等,这里也是appium中getNetworkConnection获得设备网络状态的方法

原文地址:https://www.jb51.cc/bash/389405.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐