我想通过adb检查Android应用的私有存储中是否有文件,因此我必须在命令中使用run-as <packagename>
。
但是它甚至不让我使用if
语句:
adb exec-out "run-as myPackage "if true; then echo HELLO; fi""
给run-as: exec failed for if: Permission denied
。
adb exec-out "if true; then echo HELLO; fi"
(不带run-as
)给出:HELLO
,如预期。
如何在if
命令中使用run-as
语句?
[run-as
似乎不够聪明,无法理解整个块,它需要可执行文件。
adb -d exec-out run-as myPackage sh -c "if true; then echo HELLO; fi"
sh
足够聪明。