I'm trying to add some code to help debugging an issue I've got with alarm/job scheduling on a user device, so that I can dump the current state of the alarms/jobs to a file for sending to me. I#m trying:
File outputFile;
String cmd;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
outputFile = new File(logDirectory, "jobs.txt");
cmd = "adb shell dumpsys jobscheduler > " + outputFile;
} else {
outputFile = new File(logDirectory, "alarms.txt");
cmd = "adb shell dumpsys alarm > " + outputFile;
}
Runtime.getRuntime().exec(cmd);
But I'm getting:
java.io.IOException: Cannot run program "adb": error=13, Permission denied
Thing is, running the following command in the same place in the code is fine... outputs the log to a file, so clearly file writing permissions are granted:
File logFile = new File(logDirectory, "logs.txt");
cmd = "logcat -v time -f " + logFile + " *:V";
Runtime.getRuntime().exec(cmd);