Event plugin lifecycle

83 views
Skip to first unread message

Victor Vostrikov

unread,
Feb 10, 2015, 5:35:43 AM2/10/15
to task...@googlegroups.com
Hi!

I'm writing a event plugin which will react on some data change in Content Provider and then fire event. But I do not fully understand lifecycle of such event.

  1. Lets suppose that Tasker already set up for use this plugin. When Tasker start after phone reboot - how it will notify plugin about it needed for Tasker? I read that in this case Tasker sends QUERY_CONDITION intend without message Id. But what if I want to make parametrized event and monitor change of particular data in Content Provider? Does Tasker send QUERY_CONDITION for every distinct parameter set?
  2. If condition using event plugin is changed or deleted in Tasker - how Tasker inform plugin that it must release old ContentObserver?

Pent

unread,
Feb 10, 2015, 7:53:33 AM2/10/15
to task...@googlegroups.com
>Lets suppose that Tasker already set up for use this plugin. When Tasker start after phone reboot - how it will notify plugin about it needed for Tasker? I read that in this case Tasker >sends QUERY_CONDITION intend without message Id.

Yes.


> But what if I want to make parametrized event and monitor change of particular data in Content Provider? Does Tasker send QUERY_CONDITION for every distinct parameter >set?

For every instance of the event plugin that the user has configured.
  1. If condition using event plugin is changed or deleted in Tasker - how Tasker inform plugin that it must release old ContentObserver?
There is nothing in the base protocol to allow that unfortunately, so it will stay as it is till the next system restart.

I don't want to go into the reasons here, but the issue has come up on here a few times, a search of the forum
might bring something useful.

Would also like to add that I didn't develop the base protocol.

Pent

Pent

unread,
Feb 10, 2015, 7:55:48 AM2/10/15
to task...@googlegroups.com
p.s. you don't need to reboot to test the mechanism, you can just disable then enable Tasker in the main screen then exit the
app.

Pent

Victor Vostrikov

unread,
Feb 10, 2015, 8:11:28 AM2/10/15
to task...@googlegroups.com


вторник, 10 февраля 2015 г., 15:53:33 UTC+3 пользователь Pent написал:
> But what if I want to make parametrized event and monitor change of particular data in Content Provider? Does Tasker send QUERY_CONDITION for every distinct parameter >set?

For every instance of the event plugin that the user has configured.

Ok, when I got QUERY_CONDITION without message Id, I set up Content Observer with parameters passed as Intent's Extra (let's say that it's some account Id). When content is changed, I send REQUEST_QUERY to Tasker. How must I inform Tasker that this Intent belongs to particular condition (with particular account Id)? Should I pass this account Id same as Tasker passes it to me - in Intent's Extra?

Pent

unread,
Feb 10, 2015, 8:24:24 AM2/10/15
to task...@googlegroups.com


Ok, when I got QUERY_CONDITION without message Id, I set up Content Observer

Yes, if it's not already setup.
 
with parameters passed as Intent's Extra (let's say that it's some account Id). When content is changed, I send REQUEST_QUERY to Tasker.

Yes, with some pass-through data e.g. via TaskerPlugin.addPassThroughMessageID(). Then Tasker will send you QUERY_CONDITION with the pass-through data you specified.

Complicated I know :-)

Most of the complexity comes from needing to stay compatible with the base protocol (it has no events) and security (host making sure it's talking to plugin and
vice-versa).

Pent

Victor Vostrikov

unread,
Feb 10, 2015, 8:44:33 AM2/10/15
to task...@googlegroups.com

with parameters passed as Intent's Extra (let's say that it's some account Id). When content is changed, I send REQUEST_QUERY to Tasker.

Yes, with some pass-through data e.g. via TaskerPlugin.addPassThroughMessageID(). Then Tasker will send you QUERY_CONDITION with the pass-through data you specified.

As I understand, I set MessageID to get it again (and maybe some other pass-through data) in corresponding QUERY_CONDITION. But this is not exactly that thing I asked about. 

Lets suppose that we have such configuration set up in Tasker:

Condition 1 (plugin params: account id = 1) => Task A
Condition 2 (plugin params: account id = 2) => Task B

When I set up Condition 1, my plugin got QUERY_CONDITION without message Id, and I set Content observer to monitor change of account with id 1. Then it repeats for Condition 2 and account id 2. Now I have 2 content observers which monitors it's own account Id. 

Then account 2 changes it's data, second observer gots notification, and need to send an Intent to Tasker to inform it that Condition 2 (and not Condition 1 or both of them) occured. What I need to send in REQUEST_QUERY Intent to distinct Condition 1 from Condition 2?

Or is REQUEST_QUERY Intent mean "Some of monitored conditions occured, lets send QUERY_CONDITION Intent to decide which one exactly"?

Crafty Apps Support

unread,
Feb 10, 2015, 9:20:22 AM2/10/15
to task...@googlegroups.com

>
> Then account 2 changes it's data, second observer gots notification,
> and need to send an Intent to Tasker to inform it that Condition 2
> (and not Condition 1 or both of them) occured. What I need to send in
> REQUEST_QUERY Intent to distinct Condition 1 from Condition 2?

You can send whatever you like, it's up to you.

You could add e.g. ID 2 in your REQUEST_QUERY, which will then get
passed back to you when Tasker does QUERY_CONDITION
(TaskerPlugin.retrievePassThroughData()).

>
> Or is REQUEST_QUERY Intent mean "Some of monitored conditions occured,
> lets send QUERY_CONDITION Intent to decide which one exactly"?

Yes, in REQUEST_QUERY there is no information which could tell Tasker
which plugin instance in Tasker the event refers too.

So Tasker will send a QUERY_CONDITION for each plugin instance from your
plugin that the user has setup and will include
the pass-through data from each that you supplied (2 in this case) so
that you can decide how to answer each
QUERY_CONDITION, by comparing the configuration data the user setup with
the data of the event that occurred (which you need
to pass through with the REQUEST_QUERY, either a reference to it, or the
event data itself).

You will then only reply SATISFIED for condition 2.

Pent


Reply all
Reply to author
Forward
0 new messages