0

I have the next command that allows me to copy allure results (logs, screenshots of completed tests) from /data/data/com.example/files/allure-results folder (android 10, 11) to sdcard. (i need it because sdcard is private folder on device from android 10 and i use workaround with tar process that allows me to untar required folder to protected sdcard folder)

adb exec-out "run-as com.example sh -c 'cd /data/data/com.example/files && tar cf - allure-results' | tar xvf - -C /sdcard/

When i start it from local computer terminal everything is ok. But for some reason, i have the next error if i execute this command from code via ProcessBuilder -> /system/bin/sh: no closing quote

command in code looks like:

exec("adb exec-out \"run-as com.example sh -c 'cd /data/data/com.example/files && tar cf - allure-results' | tar xvf - -C /sdcard/\"".split(" "))

How can fix it? Any ideas?

P.S. don't suggest to use TestStorage from androidx.test.services etc it doesn't fit my case and based on scratches for android < 10...

solution pass as array: https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exec(java.lang.String%5B%5D)

1 Answers1

1

I think the issue comes from the last "split()" method.

The result of splitting:

"adb exec-out \"run-as ...".split(" ")

is:

"adb", "exec-out", "\"run-as", ...

The third element in the array split() generated has a not closed ".

I would suggest to remove the .split() and to pass exec() an array of three elements.

"adb", "exec-out", "run-as ...The-rest..."
Harkaitz
  • 66
  • 2