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


↙↙↙阅读原文可查看相关链接,并与作者交流