简体   繁体   English

ADB shell 猴子命令更改设备方向锁定

[英]ADB shell monkey command changing device orientation lock

I'm using the adb shell command monkey to launch one application followed by another.我正在使用 adb shell 命令monkey启动一个应用程序,然后启动另一个应用程序。 It all works fine, except for one odd side effect where the orientation lock on the device is set back to auto-rotate.一切正常,除了一个奇怪的副作用,即设备上的方向锁定设置回自动旋转。 We usually have the tablets locked to portrait only.我们通常只将平板电脑锁定为纵向。

Is anyone aware of any reason the monkey command would change the orientation lock?有没有人知道monkey命令会改变方向锁定的任何原因? Or if there is a way to prevent this/set it back through the adb?或者是否有办法通过 adb 防止这种情况/将其设置回来?

adb shell monkey -p com.application1 1
adb shell monkey -p com.application2 1

Tablet Info:平板电脑信息:

  • Nexus 7连结 7
  • Android v6.0.1安卓 v6.0.1

As discussed in the comments above with @MartinZeitler, the problem was that the monkey command was not really suitable for the purpose I was putting it to. 正如上面对@MartinZeitler的评论中所讨论的,问题是monkey命令并不适合我的目的。 Although removing the orientation lock is not something I've been able to find explicitly documented anywhere, it looks as if this is one of the random elements monkey triggers. 虽然删除方向锁不是我能够在任何地方明确记录的内容,但看起来这似乎是随机元素monkey触发器之一。

My solution was to launch the application using the following command, which was more appropriate for just launching an application as part of another test rather than using the stress test command. 我的解决方案是使用以下命令启动应用程序,这更适合于作为另一个测试的一部分启动应用程序而不是使用压力测试命令。

am start -n com.application1/.MainActivity`

The following Question contains some really good detail on launching apps through the ADB 以下问题包含有关通过ADB启动应用程序的一些非常好的细节

How to start an application using android ADB tools? 如何使用Android ADB工具启动应用程序?

要返回锁定模式:

adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM