renyuneyun / Easer

User-defined explicit automation for Android
https://renyuneyun.github.io/Easer/
GNU General Public License v3.0
799 stars 91 forks source link

[FR] Add pre-defined Intents for selection #15

Open ildar opened 7 years ago

ildar commented 7 years ago

Actually there are many useful intents around and that would be great to have ability to "run" them

renyuneyun commented 7 years ago

Yes, definitely. In order to support this, The first thing is to extend the "send broadcast" operation to allow editing categories, data, and MIME.

Then, I'm not sure which way will be better:

  1. add a selection button/icon in the send broadcast operation part, and pick pre-defined intents there
  2. add dedicated operations for these intents (maybe all in one operation)

Also, I'm planning to change the profile editing page/dialog so users can "add" operations from a list, instead of the current "selected or not selected" way. I'm thinking of which way would be more natural.

renyuneyun commented 7 years ago

First part is already done. We can now manually set categories (seperated by newlines), data and MIME type in addition to action.

Any suggestions on how to design the second part?

ildar commented 7 years ago

An example (or better a few different examples) would help. Can you drop a link or plain text examples right here?

renyuneyun commented 7 years ago

You mean using existing intents?

Here are a few examples given by official documents.

One example may be:

Action: android.intent.action.DIAL Data: tel:123123

meaning dial the phone number 123123

jpggithub commented 6 years ago

Ok, many thanks for your informative answer. :-)

iexos commented 5 years ago

Hi, is this still waiting to be implemented?

ildar commented 5 years ago

It should work AFAIK. Did you try?

iexos commented 5 years ago

I couldn't get it to work. Maybe I understand intents wrong, but I came to the conclusion that broadcasts and intents to start activities are different things.

I am trying to activate SD Scanner from easier but cannot make it. In the link is a description for how to activate with Tasker, I hoped I could do it similarly with Easer.

ildar commented 5 years ago

I'd suggest:

  1. trying https://f-droid.org/packages/de.szalkowski.activitylauncher/ to have a working scenario
  2. look what's in adb logcat when SD scanner doesn't get started.
  3. type in the exact values you used here.
iexos commented 5 years ago

@ildar thank you for your support.

  1. I have tried the Activity Launcher app you suggest. It crashes when trying to start SD Scanner
  2. I have tried the Launch App function in Easer, as you can now pass a class name which i set to com.gmail.jerickson314.sdscanner.MainActivity. It crashes the same as 1.
    04-02 21:05:45.951 E/AndroidRuntime(17325): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gmail.jerickson314.sdscanner/com.gmail.jerickson314.sdscanner.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
  3. It works as intended via command line:
    
    $ am start -a android.intent.action.RUN -n com.gmail.jerickson314.sdscanner/.MainActivity
    Starting: Intent { act=android.intent.action.RUN cmp=com.gmail.jerickson314.sdscanner/.MainActivity }
04-02 20:33:40.032 I/ActivityManager(1279): START u0 {act=android.intent.action.RUN flg=0x10000000 cmp=com.gmail.jerickson314.sdscanner/.MainActivity} from uid 10091 on display 0 ``` 4. Trying via command line broadcast does not nothing. Output: ``` $ am broadcast -a android.intent.action.RUN -n com.gmail.jerickson314.sdscanner/.MainActivity Broadcasting: Intent { act=android.intent.action.RUN cmp=com.gmail.jerickson314.sdscanner/.MainActivity } Broadcast completed: result=0 ``` 5. I tried many different things with Send Broadcast in Easer, to no avail. Always Action as `android.intent.action.RUN`, then custom keys exactly as in the SD Scanner description (Class, Package, Target) or leaving out some of them, or trying Class `com.gmail.jerickson314.sdscanner/com.gmail.jerickson314.sdscanner.MainActivity` or variations of this. I also tried custom key `cmp` with value `com.gmail.jerickson314.sdscanner/com.gmail.jerickson314.sdscanner.MainActivity` and variations. Never got a response.
ildar commented 5 years ago

This is actually SD Scanner that crashes: https://github.com/jerickson314/sdscanner/issues/24 I see two things you could try:

  1. varying params of intent in Easer . E.g. ...sdscanner/.MainActivity versus ...sdscanner.MainActivity
  2. starting MediaService directly without SD Scanner
iexos commented 5 years ago

You are right, it is SD Scanner that is crashing. But it should be possible to trigger the same action as am start with Easer that is doing the correct thing.

  1. I was varying this in several ways, always trying the shorter and longer written form.
  2. What MediaService would that be? The whole point of existence for SD Scanner is that there is no built-in function in Android anymore that you can use to scan more than a single file at a time.

Unfortunately am start is not working via the command in Easer, its also not working in the LOS built-in terminal with the binary /system/bin/am (it gives an exception that permission INTERACT_ACROSS_USERS_FULL is necessary). It is working in termux though, which brings its own flavor of am.

renyuneyun commented 5 years ago

Whoops, I didn't notice there is a conversation going on LOL .

Thank you a lot for the help @ildar . (Both of) Your discussions made the things more clear to me, and I think I have a conclusion / solution.

@iexos Have you tried not to write any class name in the Launch App Operation (i.e. only write the package name)? I just tested it on my side, and it works without crashing.

FYI, yes, as you have seen yourself, am start and am broadcast are two different things, as well as the Intent. In the Send Broadcast Operation, it just does broadcast, won't do "start activity" or "start service". It seems a bit messy to have both functions in Send Broadcast Operation from my point of view, especially when "launch app" can have a selection of apps (not implemented yet, I have to admit) while send broadcast doesn't.

Maybe we should rename this issue as something like "allow to choose from pre-defined Intents"? Or just open another issue.

iexos commented 5 years ago

@renyuneyun thank you for clearing this up. I think I understand now what is going on.

Without the class name it starts the application as you would expect, but without performing the actual scan, as am broadcast -a android.intent.action.RUN -n com.gmail.jerickson314.sdscanner/.MainActivity does

So as i understand it, the missing part would be to choose "action" for Launch App.