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)