2

I try to execute "am profile start " within my Android app to profile another PID. From ADB everything works fine, for example: adb shell am profile 5397 start /sdcard/my.app.trace works. But trying to execute "am" or "pm", or anything that executes app_process gives the following error:

/system/bin/am[8]: app_process: can't execute: Permission denied

It also does not work from a terminal emulator, same error. If I am executing it (both on adb or on device) with root the Segmentation Fault like here occurs: Segmentation Fault executing pm on android. The answers there did not solve my problem with accessing "am" with root, however I would like to solve the problem to run the command without root. There is a problem with executing app_process on the device which I am not able to solve. I am using a rooted Nexus 5 with the Android L Preview. With my old rooted Motorola Milestone the commands run on the terminal emulator. Here is the code for just trying to execute the "am" command within my app which should list the options of that command but produces the error above.

    try {

        String outputString;
        String command = "am";

        Log.d(TAG, "EXECUTING CMD: " + command);
        // execute command and read output
        process = Runtime.getRuntime().exec(command);

        BufferedReader stdError = new BufferedReader(new InputStreamReader(
                process.getErrorStream()));

        BufferedReader stdInput = new BufferedReader(new InputStreamReader(
                process.getInputStream()));


        while ((outputString = stdInput.readLine()) != null) {
            Log.d(TAG, " EXECUTING CMD Here is the standard output of the command (if any):\n");
            Log.d(TAG, outputString);
        }


        while ((outputString = stdError.readLine()) != null) {
            Log.d(TAG, "EXECUTING CMD Here is the standard error of the command (if any):\n");
            Log.d(TAG, outputString);
        }
        Log.d(TAG, "****** / " + sCmd + " *******");
    } catch (IOException exception) {
        exception.printStackTrace();

    }
Community
  • 1
  • 1
julia3072
  • 21
  • 3

0 Answers0