1

I'd like to know how would it be possible to launch an action "shortcut" (like Greenify's auto-hibernation shortcut) through the command line in Android.

I'm trying to launch a StrongSwan VPN profile on boot, but first I need to know what command does eg. the launcher send to it while launching the profile from the home screen.

So far, what I've managed to observe is that when I launch SS with that shortcut, the logcat says:

START u0 {act=org.strongswan.android.action.START_PROFILE flg=0x10000000 cmp=org.strongswan.android/.ui.MainActivity bnds=[360,1759][540,1920] (has extras)} from uid 10077 on display 0 

Any ideas on how to make it into command input? Thanks in advance!

migrated from superuser.com Sep 16 '17 at 15:17

This question came from our site for computer enthusiasts and power users.

  • 1
    Any good reason why you only want a command-line solution? The profile may be launched through the help of an another app. – Firelord Sep 16 '17 at 15:49
  • Technically it doesn't have to be a CLI solution, but I guess it would be easier. I've looked for apps that could do this EXACT thing, but I've found none. Most of them, for example Tasker, can only launch specific activities, but there seems a need for some specific data to be supplied in order for the profile to be launched. Is there any app that would do that? Or extract/intercept the command that is executed whenever I tap the shortcut (labeled "Connect to (servername)" in eg. my launcher? – Super Suer Sep 16 '17 at 18:00
1

Looking for an intent interceptor I came across IntentTask which is helpful for your objective. I installed Tasker, that app, setup a Task with action:

Plugin → IntentTask → Launch Shortuct → Configuration: tap pencil icon → your app → the profile.

The intent auto-populated there was:

#Intent;action=org.strongswan.android.action.START_PROFILE;l.org.strongswan.android.VPN_PROFILE_ID=1;end

You can now attach your task to a boot profile in Tasker now.

As for the command-line I tried the same intent in the command-line and it works too.

am start -a org.strongswan.android.action.START_PROFILE --el org.strongswan.android.VPN_PROFILE_ID 1

Replace 1 with the your profile's ID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.