Problem starting activity command line

Post your questions and help other users.

Moderator: Martin

Post Reply
arboeh
Posts: 5
Joined: 18 Jul 2014 14:06

Problem starting activity command line

Post by arboeh » 20 Apr 2020 06:17

I have a problem starting an activity with Xiaomi Mi Home app (V5.6.75) from command line:

Code: Select all

am start "intent:#Intent;component=com.xiaomi.smarthome/.scene.SmartHomeLauncherActivity;S.extra_scene_account=1111111111;l.profile=0;i.extra_scene_id=222222222;end"
Error log message is

Action 'Kommandozeilenbefehl ausführen: am start "intent:#Intent;component=com.xiaomi.smarthome/.scene.SmartHomeLauncherActivity;S.extra_scene_account=1906229605;l.profile=0;i.extra_scene_id=473287919;end" in ' stderr=Security exception: Permission Denial: startActivityAsUser asks to run as user -2 but is calling from uid u0a141; this requires android.permission.INTERACT_ACROSS_USERS_FULL

If i put command "--user 0" in the command line string there is no error in the log any more, but activity won't start and popup "Execution not possible" occures.
Is there a solution, or is it only possible to run that activity with root access?
I tried the action "Start Activity" too, but same problem.

Btw: Automagic is a great app!

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Problem starting activity command line

Post by Desmanto » 20 Apr 2020 16:25

Some app protect their own intent to be launched externally. Google usually do this too to their app, example I can't launch Google lens directly. But Google Cam can call it properly

Is it possible to build shortcut to the scene you need in Mi Home. Because if you can add it as manual shortcut, you can build it using action Launch Shortcut.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

arboeh
Posts: 5
Joined: 18 Jul 2014 14:06

Re: Problem starting activity command line

Post by arboeh » 28 Apr 2020 16:24

I can create a shortcut for this scene, but I can't select it in Automagic using Launch Shortcut. :|

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Problem starting activity command line

Post by Desmanto » 29 Apr 2020 14:58

If you can create the shortcut, but can't use normal launcher shortcut creator or Automagic's launch shortcut, then it must be the deeplink shortcut type. Some call it sesame shortcut.
There has been a request so Automagic support this shortcut, by exposing the trigger shortcut to the deeplink type : viewtopic.php?f=4&t=7942

However, in your case, it will be the reverse, create an action in Automagic so it supports to open other deeplink shortcut. Currently I have tried with Start activtiy and am start-activity as you have tried, and still can't launch it properly or get the same permission denial error as yours. This is the same problem with launch PWA link in full screen as in here : viewtopic.php?f=5&t=8672#p27909

I wonder how you get the intent detail. I use nova launcher database to get the full detail, as shown in above link. I hope there is a faster way to get it.
From what I have tried, only main launcher app can perform this type of deeplink shortcut. So the workaround is to install additional plugin Intentask : https://play.google.com/store/apps/deta ... intenttask
Set it as default launcher and then choose your current launcher. Let intentTask populate all deeplink, then you can use the action plugin > Launch App shortcut > Choose the smarthome and choose the scene you have as the deep link. This also work for PWA deeplink for Chrome.

I wonder if Automagic can implement this built-in. Since it is also a kind of shortcut, deeplink shortcut. Since I don't want to install additional app just for single function (intentTask can do much more, but most of the function already there in Automagic). I think there is some java code method to do it, but I still don't know where to start.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

arboeh
Posts: 5
Joined: 18 Jul 2014 14:06

Re: Problem starting activity command line

Post by arboeh » 29 Apr 2020 15:26

I solved it. Found a solution in a chinese forum. :D
Xiaomi changed the name of one parameter and from Integer to String lately.
I have a rooted tablet and was able to get the Xiaomi scene parameters from a config file from there. Its tricky. I can help you with that now if you want.
I'm able to start Mijia cam after leaving house now eg.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Problem starting activity command line

Post by Desmanto » 29 Apr 2020 16:22

Oh. You also do it using root access. Maybe I need to use the SQLite flow to automate parsing the link from nova launcher database. That can be done later.
Now, I just want to know the exact command you use to start the deep shortcut. Thanks in advance.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

arboeh
Posts: 5
Joined: 18 Jul 2014 14:06

Re: Problem starting activity command line

Post by arboeh » 29 Apr 2020 18:40

Screenshot_20200429-203742.png
Screenshot_20200429-203742.png (88.68 KiB) Viewed 15511 times
You have to change the number values for your use!

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Problem starting activity command line

Post by Desmanto » 30 Apr 2020 17:42

Hmmm, if it works in your case, that means my google camera intent is correct too already. Maybe I still need to play with the extra value. Probably it is time to decompile and check the proper extra needed. Thanks for the sharing.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply