问题
I'm trying to broadcast an adb-command to a broadcast-receiver. This would be a very simple task, but the braodcast-receiver has:
android:exported="false"
On the offical android.developer website, it says:
If "false", the only messages the broadcast receiver can receive are those sent by components of the same application or applications with the same user ID.
So I'm trying to add the user ID to the broadcast. My approach by now is the following adb command:
> adb shell am broadcast -a com.example.action -n com.android.package/.receiverName --user "User_ID"
I get Error: Invalid int: "User_ID"
in the cmd under Windows. This app is a System-app, more precise, it is the default Phone-App. I thought an Adb command is a system broadcast by default. My question therefor is: Is there any way to to send the User ID with the broadcast or to access not exported actions? Is there maybe a difference between the User_ID of the manifest and the User_ID of the am broadcast. Thanks in advance
P.S: I haven't got any root access, because it should work for a lot of devices without rooting everyone. As final result I want to accept an incoming videocall as Audiocall.
回答1:
There are totally different user.
The first "user", in android website, is the user id in linux system, like root,system,u0_a58(10058). Every APK has it's user id, unless in share UID condition.
The second "user", in the am command, is the user stand for people who using this phone, like administrator, guest.
(You can add Guest user in Android Tab, but you can not do it in a Android phone, due to some legal stuff.)
The answer: there is no way to access not exported component from a non-root shell or 3rd APK.
来源:https://stackoverflow.com/questions/34047962/adb-broadcast-with-user-id