Passing command line argument when launching app in streamline

Hi Forum,

In streamline tool, I don't see any way to pass command line argument to the app when launching. Because of this I need to rebuild the apk and reinstall every time I need to change the command line argument.

Is there a work around to this problem?

Thank you,

rchakena

Parents
  • Hi rchakena,

    You can start the application how you'd like via the am command in adb shell.  You would also have to manually copy the gator agent onto the device and run it as the same user as your app, instructing gator to profile using your app's package name.  Streamline would connect to gator via adb's port forwarding.

    In your streamline directory we package builds of gator that can be copied to the device.  For the rest of this example I'll use the one in

      streamline/bin/android/arm64/gatord

    since I'm presuming a 64bit android target.

    1. Start streamline.

    2. Push gatord to the target:

       $ adb push streamline/bin/android/arm64/gatord /data/local/tmp

    3. adb shell onto the target.

       $ adb shell

    4. On some target devices perf hardening may be on, which blocks gatord from collecting data via perf.  Gatord needs this, so to disable perf hardening:

       $ getprop | grep perf_harden  # check what its current value is, so you can restore it back
       $ setprop security.perf_harden 0

       After you have finished profiling you can restore the previous value with

       $ setprop security.perf_harden <the-previous-value>

    5. Switch to your program's user

       $ run-as <YourAppsPackage>

    6. You may not be able to execute gatord in the /data/local/tmp directory, so copy it into your app's directory (which should be the current dir).

       $ cp /data/local/tmp/gatord .

    7. Run gator as your program's user, specifying the package name

       $ ./gatord --wait-process <YourAppsPackage>

    8. In streamline switch to the TCP (Advanced) tab.  There should be an entry in the table corresponding to your device.  Select it.

    9. Start the capture by pressing 'Start Capture'

    10. Start your app how you like.  You can use a separate adb shell to start it with am, supplying your arguments.


    Andrew

Reply
  • Hi rchakena,

    You can start the application how you'd like via the am command in adb shell.  You would also have to manually copy the gator agent onto the device and run it as the same user as your app, instructing gator to profile using your app's package name.  Streamline would connect to gator via adb's port forwarding.

    In your streamline directory we package builds of gator that can be copied to the device.  For the rest of this example I'll use the one in

      streamline/bin/android/arm64/gatord

    since I'm presuming a 64bit android target.

    1. Start streamline.

    2. Push gatord to the target:

       $ adb push streamline/bin/android/arm64/gatord /data/local/tmp

    3. adb shell onto the target.

       $ adb shell

    4. On some target devices perf hardening may be on, which blocks gatord from collecting data via perf.  Gatord needs this, so to disable perf hardening:

       $ getprop | grep perf_harden  # check what its current value is, so you can restore it back
       $ setprop security.perf_harden 0

       After you have finished profiling you can restore the previous value with

       $ setprop security.perf_harden <the-previous-value>

    5. Switch to your program's user

       $ run-as <YourAppsPackage>

    6. You may not be able to execute gatord in the /data/local/tmp directory, so copy it into your app's directory (which should be the current dir).

       $ cp /data/local/tmp/gatord .

    7. Run gator as your program's user, specifying the package name

       $ ./gatord --wait-process <YourAppsPackage>

    8. In streamline switch to the TCP (Advanced) tab.  There should be an entry in the table corresponding to your device.  Select it.

    9. Start the capture by pressing 'Start Capture'

    10. Start your app how you like.  You can use a separate adb shell to start it with am, supplying your arguments.


    Andrew

Children