From 3b68dfc126ffc5e3a159b49451aef50d3ebd639f Mon Sep 17 00:00:00 2001 From: Zhuang Ma Date: Thu, 1 Dec 2016 19:37:59 +0800 Subject: [PATCH] Add commands to modify settings, ref #11 --- README.en.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) diff --git a/README.en.md b/README.en.md index 2dab379..6c3e118 100644 --- a/README.en.md +++ b/README.en.md @@ -77,6 +77,8 @@ Other languages: [:cn: Chinese](./README.md) * [Resolution](#resolution) * [Screen density](#screen-density-1) * [Overscan](#overscan) + * [Turn off Android Debug](#turn-off-android-debug) + * [Show/hide status bar or navigation bar](#showhide-status-bar-or-navigation-bar) * [Utility functions](#utility-functions) * [Screenshots](#screenshots) * [Recording Screen](#recording-screen) @@ -1647,6 +1649,64 @@ Reset to original overscan: adb shell wm overscan reset ``` +### Turn off Android Debug + +command: + +```sh +adb shell settings put global adb_enabled 0 +``` + +To reset: + +We can't do this via command now, because without "Android Debug" on, adb cannot communicate with Devices. + +So just do it on device manually: + +"Settings" - "Developer options" - "Android Debug". + +### Show/hide status bar or navigation bar + +Settings in this section correspond with "Expanded desktop" in Cyanogenmod. + +command: + +```sh +adb shell settings put global policy_control +``` + +`` composite by keys and their values below, format is `=:=`. + +| key | meaning | +|-----------------------|---------------------| +| immersive.full | Hide both | +| immersive.status | Hide status bar | +| immersive.navigation | Hide navigation bar | +| immersive.preconfirms | ? | + +Values for these keys are comma-delimited list of tokens, where tokens: + +| value | 含义 | +|----------------|------------------| +| `apps` | All applications | +| `*` | Everywhere | +| `packagename` | Include package | +| `-packagename` | Exclude package | + +For example: + +```sh +adb shell settings put global policy_control immersive.full=* +``` + +Means set hide both status bar and navigation bar everywhere. + +```sh +adb shell settings put global policy_control immersive.status=com.package1,com.package2:immersive.navigation=apps,-com.package3 +``` + +Means set hide status bar in applications whoes package name is `com.package1` or `com.package2`, hide navigation bar in all applications, exclude whoes package name is `com.package3`. + ## Utility functions ### Screenshots diff --git a/README.md b/README.md index 6878952..d5af618 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,8 @@ Other languages: [:gb: English](./README.en.md) * [分辨率](#分辨率) * [屏幕密度](#屏幕密度-1) * [显示区域](#显示区域) + * [关闭 USB 调试模式](#关闭-usb-调试模式) + * [状态栏和导航栏的显示隐藏](#状态栏和导航栏的显示隐藏) * [实用功能](#实用功能) * [屏幕截图](#屏幕截图) * [录制屏幕](#录制屏幕) @@ -1599,6 +1601,8 @@ adb shell cat /system/build.prop **注:**修改设置之后,运行恢复命令有可能显示仍然不太正常,可以运行 `adb reboot` 重启设备,或手动重启。 +修改设置的原理主要是通过 settings 命令修改 /data/data/com.android.providers.settings/databases/settings.db 里存放的设置值。 + ### 分辨率 命令: @@ -1647,6 +1651,62 @@ adb shell wm overscan 0,0,0,200 adb shell wm overscan reset ``` +### 关闭 USB 调试模式 + +命令: + +```sh +adb shell settings put global adb_enabled 0 +``` + +恢复: + +用命令恢复不了了,毕竟关闭了 USB 调试 adb 就连接不上 Android 设备了。 + +去设备上手动恢复吧:「设置」-「开发者选项」-「Android 调试」。 + +### 状态栏和导航栏的显示隐藏 + +本节所说的相关设置对应 Cyanogenmod 里的「扩展桌面」。 + +命令: + +```sh +adb shell settings put global policy_control +``` + +`` 可由如下几种键及其对应的值组成,格式为 `=:=`。 + +| key | 含义 | +|-----------------------|------------| +| immersive.full | 同时隐藏 | +| immersive.status | 隐藏状态栏 | +| immersive.navigation | 隐藏导航栏 | +| immersive.preconfirms | ? | + +这些键对应的值可则如下值用逗号组合: + +| value | 含义 | +|----------------|--------------| +| `apps` | 所有应用 | +| `*` | 所有界面 | +| `packagename` | 指定应用 | +| `-packagename` | 排除指定应用 | + +例如: + +```sh +adb shell settings put global policy_control immersive.full=* +``` + +表示设置在所有界面下都同时隐藏状态栏和导航栏。 + +```sh +adb shell settings put global policy_control immersive.status=com.package1,com.package2:immersive.navigation=apps,-com.package3 +``` + +表示设置在包名为 `com.package1` 和 `com.package2` 的应用里隐藏状态栏,在除了包名为 `com.package3` 的所有应用里隐藏导航栏。 + ## 实用功能 ### 屏幕截图