移动测试基础 New Command Line Tool ‘settings’ in Android 4.2

恒温 · 2014年09月18日 · 最后由 恒温 回复于 2014年09月19日 · 1258 次阅读

There is a new binary shipping with Android Jellybean 4.2, which can be used to directly read/write to the system settings provider, accessible via command line.

This tool also makes it easy to change system settings using shell commands (Github source). Since adb is run as a system process, using ‘adb shell’ allows full read/write. If these commands are run from within an application, it requires the appropriate permissions unless it is being run with elevated permissions (root).

settings

usage: settings [--user NUM] get namespace key
settings [--user NUM] put namespace key value
'namespace' is one of {system, secure, global}, case-insensitive
If '--user NUM' is not given, the operations are performed on the owner user.

Corresponding keys can be found in the frameworks core Settings.java (Github source).
https://github.com/android/platform_frameworks_base/blob/master/core/java/android/provider/Settings.java

It can be used to get system state without explicit API calls. For example, change screen brightness to 200 (1-255):

settings put system screen_brightness 200

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 3 条回复 时间 点赞

这个作用类似于百度 cafe 的那个 service 的作用。 不过功能还只限于 settings。

#1 楼 @seveniruby 嗯 目前就是 setting,其实就是那个 sqlite3 的数据库。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册