Shi*_*bMe 28 automation android adb ui-automation
我在真实设备上使用Android 4.4,我想通过设置设备方向adb.我不希望它与uiautomator完成,因为它不会在uiautomator代码终止后持续.
我怎样才能做到这一点?
小智 57
您可能首先需要关闭自动旋转
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0
Run Code Online (Sandbox Code Playgroud)
旋转到风景
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1
Run Code Online (Sandbox Code Playgroud)
旋转肖像
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:0
Run Code Online (Sandbox Code Playgroud)
wrk*_*wrk 38
而不是使用"adb shell内容",使用"adb shell设置"有一种更干净的方式.他们正在做同样的事情,为设置提供商提供价值.
adb shell settings put system accelerometer_rotation 0 #disable auto-rotate
adb shell settings put system user_rotation 3 #270° clockwise
Run Code Online (Sandbox Code Playgroud)
accelerometer_rotation: auto-rotation, 0 disable, 1 enableuser_rotation: actual rotation, clockwise, 0 0°, 1 90°, 2 180°, 3 270°Ben*_*nny 15
禁用accelerometer_rotation并设置user_rotation
user_rotation Values:
0 # Protrait
1 # Landscape
2 # Protrait Reversed
3 # Landscape Reversed
Run Code Online (Sandbox Code Playgroud)
accelerometer_rotation Values:
0 # Stay in the current rotation
1 # Rotate the content of the screen
Run Code Online (Sandbox Code Playgroud)
adb shell settings put system accelerometer_rotation 0
adb shell settings put system user_rotation 3
Run Code Online (Sandbox Code Playgroud)
import android.provider.Settings;
// You can get ContentResolver from the Context
Settings.System.putInt(getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0);
Settings.System.putInt(getContentResolver(), Settings.System.USER_ROTATION, 3);
Run Code Online (Sandbox Code Playgroud)
wm cmd 可用于在 adb shell 上设置用户轮换
wm help
user-rotation [free|lock] [-d DISPLAY_ID] [rotation]
Set user rotation mode and user rotation.
Run Code Online (Sandbox Code Playgroud)
例子:
wm user-rotation lock 0
wm user-rotation lock 1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
40519 次 |
| 最近记录: |