Open Source • Background Tasks: Itoo 🚀

Itoo can only support these icons, drawables names starting from ic_ (icon) are the ones mainly used. I'll take a look, what I can extend the support to in future.

1 Like

Ok. Thanks! That explains it.

My guess is that other enhancements would be more important and useful to your itoo users than a richer icon set :slight_smile: ... But it might be nice, if it turns out not to be too much effort. You might mention the "ic_" only icon set (found in Android docs) in the next documentation update.

Kind regards,
Randal

How can I assure that a sequence of blocks in a procedure will be executed atomically/exclusively if the procedure is called by both foreground user interface code and a foreground service (as defined in the documentation)?

An example requiring this functionality might be incrementing a counter that is stored using itoo.StoreProperty. The count must be Fetch'd, incremented, and then Store'd from procedure, IncrementCounter, which contains the necessary blocks.

Without some sort of semaphore/lock/test-and-set mechanism, if both service and UI calls overlap, a count can be missed, their being generated a duplicate increment of some value.

I sense that the itoo Broadcast mechanism may be the solution (perhaps BroadcastEvent is the exclusive, serializing code), but my experimenting with it has proved fruitless. (BTW, in any case, I would like an example that illustrates the use of BroadcastEvent, RegisterBroadcast, and Broadcast. Perhaps one has been posted somewhere in this thread.)

Any comments or other help would be greatly appreciated.

Kind regards,
Randal

To avoid that problem, what about calling that procedure only from the foreground service?

You might want to provide a screenshot of what you are doing...

Taifun

I think I can explain without code,,, I am still working on the data transport monitor. The user interface is used, when needed, to set parameter(s) such as how often to check for changes (wifi vs cell). However, internally the service may determine that the parameter(s) need to be changed such as in the following scenario:

  • The user has set the monitor period to "snooze" (with monitor interval on the order of a few hours) b/c user 1) doesn't expect there to be wifi around and 2) he doesn't want to be bothered with constant notifications that cell data is all he has.

  • However, if wifi should become available (i.e., the app service detects a data transport change back to wifi), then the user would want the monitor app to begin checking "frequently" (every minute or so), because if the user happens to begin using data (from wifi), then he would want to know quickly if the wifi he is using is no longer available.

  • This requires the service to change parameters from "snooze" to "frequently". and if the user interface is also "up" and the user is making changes, say, from "snooze" to "hibernate" (a very long period), then there could be a collision.

The above is very unlikely and would not be fatal - if the service was first and the UI was last, the monitor would sleep when it should be "on the job". (sanity would be restored once the "hibernate" time ran out). But there may be other parameter changes which could result in some unanticipated state... so I just wanted to see what was possible as far as exclusivity/locks.

[after thought ... perhaps I could have the service post a notification that the user should make the change ... but the user may miss the notification and it could be a Looooong time till the next one :slight_smile: ... hmmm.]

-Randal

A post was split to a new topic: Trying to download some pictures

Ahh, hmm, I'm sorry, I dont understand you very well.
Could you please simplify the explanation of this problem with a simple demonstration if possible? That would be great for understanding what limits you.

Could you help me in some way how to change the icon by default, since one assigns a bell to it but if for some reason the service is closed and it opens automatically it puts the microphone back, as if from the root it has the microphone by default

I will put something together and try to get it to "mis-behave" :slight_smile: If I am successful, I will post it.

-Randal

1 Like

Hi, I will do that by this evening.

Hi
I have tried to use itoo to autorun an app when restart phone.

At first on installing apk and running app, it plays the voice and runs the assigned app to run: facebook

On restart of phone, it just plays the voice and does not run the app: facebook.

Is it possible to use itoo to autorun apps?

Here is my blocks:

Can you please take another screenshot so we also can see these blocks in white?

What is the purpose of the packagemanager extension in this case?
Did you try the activity starter to start Facebook?

Use logcat to find out if any error occurs

Taifun

Hello, check the settings of the mobile phone on battery and others so that I can set it to start manually, that helped me.

This is generally a good advice, see also dontkillmyapp.com

In this case however something happens on restart of the device, but only partially

Taifun

1 Like

It's a shame that at the code level you can't do anything to avoid many of these things.

Hi
The white blocks are actually disabled and not in use.

The taifun package manager was originally used to launch an app but its disabled and not used, instead using package utilities to run app.
But both does not launch an app.

Will try out using activity starter.

I'm not sure if this is possible, when you reboot your phone, a lot of activities or functions are restricted. This could also be imposed for starting external apps.

This is generly done by the Android system to prevent overload after the phone starts.

Though I would recommend you to stil experiment with different methods and by also disabling device specific optimization if any (dontkillmyapp.com)

Here is an illustration of the kind of "parallel/concurrent" access that I want to be able to do - without collision between the user interface and the service.

Two timers: one running in the visible user interface and another in the itto service. Each is incrementing its own count as well as a shared count.

If there were no shared count interference - i.e., if each reads, increments, and writes the shared count without the other intervening with its identical operations, then the sum of the individual counts would be equal to the shared count...which it is initially. However, eventually, it is not.

Open the app, then press start. Open the app again and use the button to check the counts periodically.

I know this is only a toy - with no useful function - except to illustrate the kind of exclusive access I am speaking of.

itoo_sandbox_async.aia (879.7 KB)

-Randal

1 Like

Hi
Okay thanks.
Will try and experiment other methods.

1 Like

Hmm, I took a look into that. This is a race condition, which leads to inconsistent data outcomes.

Itoo's Service runs on a different process than that of the app, so they will always remain non-synced.

From what I understand, you need a mechanism where the write/read is done safely. Meaning when the data is being read/write, no other process should do the same. Thus avoiding data inconsistency.

This would require us to create a "lock" mechanism, similar to that offered by Java, where a particular block of code, even called by many different processes, execute in order-of-call.

Did I understand that correctly, what you were trying to convey me? Then please reply yes.
Also, if you are interested, you can sponsor a new extension for $15 (I'll try to solve this race condition issue)