Registered Member
|
Hi,
I was curious to see if there was a possibility to use the run command plugin of KDE Connect from automate, an android automation app. In automate I noticed there was a RunCommandWidget receiver. (An intent broadcast receiver is used to receive inter-app messaging.) Upon looking in the source code (more specifically the file RunCommandWidget.java I saw the onReceive method, the name of which suggests it will be called when a broadcast is sent to it. onReceive method in RunCommandWidget.java
First the method checks if the intent's action is equal to "RUN_COMMAND_ACTION". This suggests that the action field of the broadcast should be set to RUN_COMMAND_ACTION. Afterwards the method gets the values for TARGET_COMMAND and TARGET_DEVICE from the intent's extras. After some searching I found that the extras of an intent is a dictionary, so I assume I have to add two field to said dictionary. One with the key TARGET_COMMAND and the name of the command I want to run as a String for its value. The second with key TARGET_DEVICE and the name of the device as the value. So when looking at this method it appears the broadcast needs to contain:
So I filled in those details in automate as shown in this screenshot. note: the screenshot shows "TARGET_DEVICE" as String instead of just "TARGET_DEVICE" but I tested both without any difference However the KDE Connect app crashes every time I execute it. So I went to check the bug report from my phone. The first crash produced the following exception:
However all crashes afterwards produced a different exception:
I assume the app is crashing on this line in because RunCommandPlugin.class returns null, which causes getPlugin to raise an exception. RunCommandWidget.java (line 39)
What I fail to understand is why RunCommandPlugin.class would return a null value (as well as why the first crash is different). The widget itself definitely works on my phone as I've been using it for months. My best guess at the moment is that the widget on my homescreen initializes other values or runs additional code when I use it to run a command. I've tried a bit to google how to use RunCommandWidget receiver, but I don't expect anyone else has had such an obscure issue, and the receiver was probably never meant for use outside the widget anyways. (Or maybe I'm just bad at googling, also a reasonable possibility.) To confirm this I would have to learn the workings of the app (or at least the run commands plugin), something I currently don't really have the time for and which would be slowed down massively by the fact I don't know any java, or a language similar to it for that matter. Anyways, apologies for any bad formatting or explanations, first time posting. Regards, Udragg |
Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]