Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broadcast not accepted by Android system #470

Open
Zimbelstern opened this issue Apr 13, 2023 · 2 comments
Open

Broadcast not accepted by Android system #470

Zimbelstern opened this issue Apr 13, 2023 · 2 comments
Labels
bug General label for all bugs (i.e. things not working as intended)

Comments

@Zimbelstern
Copy link

Zimbelstern commented Apr 13, 2023

Easer version
0.8.3-beta3

To Reproduce
Settings of Send Broadcast to reproduce the behavior:

  • package: info.varden.hauk
  • class: info.varden.hauk.global.Receiver
  • action: info.varden.hauk.START_ALONE_THEN_MAKE_TOAST
  • extras:
    • source: test (string)
    • requestLink: test (string)

Error log (warning) from BroadcastQueue:

Background execution not allowed: receiving Intent { act=info.varden.hauk.START_ALONE_THEN_MAKE_TOAST flg=0x10 } to info.varden.hauk/.global.Receiver

Sending broadcast through command isn't possible either:

am broadcast -a info.varden.hauk.START_ALONE_THEN_MAKE_TOAST -n info.varden.hauk/.global.Receiver -e source test -e requestLink test

results in the warning

Permission Denial: broadcast asks to run as user -2 but is calling from uid u0a189; this requires android.permission.INTERACT_ACROSS_USERS_FULL or android.permission.INTERACT_ACROSS_USERS

from ActivityManager.

Extra phone info:
Bug reproduced on

  • Physical device running LineageOS 20
  • Virtual device running Android 13.0

Additional context
The broadcast is addressed to Hauk.

@Zimbelstern Zimbelstern added the bug General label for all bugs (i.e. things not working as intended) label Apr 13, 2023
@sudomain
Copy link

sudomain commented May 15, 2023

I think I'm experiencing the same issue but with sending a broadcast to a different app (KeyMapper). I'm trying to send an intent to KeyMapper with the following settings:
Screenshot_20230515-125337

I know it works from the KeyMapper side because I can trigger it with Termux's version on am:
am broadcast -a io.github.sds100.keymapper.ACTION_TRIGGER_KEYMAP_BY_UID --es io.github.sds100.keymapper.EXTRA_KEYMAP_UID 5344b82e-e269-473b-a19f-9c01cf4ed634

It seems the broadcast profile is broken

@bfabiszewski
Copy link

The problem is that applyDynamics method ignores target package and target class. Without the data the broadcast is implicit which is not allowed on Android 8+. Also extras are lost here.
A quick fix is as follows. I did not go any deeper though, so it may break some other stuff as the class is used in other Intent actions. I also add ACCESS_BACKGROUND_LOCATION permission. I think it is needed to start background location in controlled app.

diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 0b8d99ca..cf238990 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -8,6 +8,7 @@

     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
diff --git a/app/src/main/java/ryey/easer/skills/operation/intent/IntentOperationData.java b/app/src/main/java/ryey/easer/skills/operation/intent/IntentOperationData.java
index e39fbfac..c568bbd0 100644
--- a/app/src/main/java/ryey/easer/skills/operation/intent/IntentOperationData.java
+++ b/app/src/main/java/ryey/easer/skills/operation/intent/IntentOperationData.java
@@ -225,7 +225,13 @@ public class IntentOperationData implements OperationData, Reused {
                 String type = extra.type;
                 extras.add(new ExtraItem(key, value, type));
             }
-            data.extras = Extras.mayConstruct(extras);
+            intentData.extras = Extras.mayConstruct(extras);
+        }
+        if (data.target_package != null) {
+            intentData.target_package = data.target_package;
+        }
+        if (data.target_class != null) {
+            intentData.target_class = data.target_class;
         }
         IntentOperationData ret = new IntentOperationData(intentData);
         ret.setSkillID(skillID());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug General label for all bugs (i.e. things not working as intended)
Projects
None yet
Development

No branches or pull requests

3 participants