termux / termux-api

Termux add-on app which exposes device functionality as API to command line programs.
https://f-droid.org/en/packages/com.termux.api/
2.25k stars 449 forks source link

Add CronAPI #657

Open lvogt opened 7 months ago

lvogt commented 7 months ago

This implements a cron-like API which uses AlarmManager and WorkManager

WorkManager is used to keep phone awake during task execution, and to be able to handle constraints - including stopping the task if constraint is no longer met.

Until now this has been only tested in the emulator, testing on my actual phone is next on my list. So consider this PR a "draft" but I wanted to get this out to get some "earlier" feedback about the whole concept.

Part of this relies on https://github.com/termux/termux-app/pull/3821 PR for api-packages script: https://github.com/termux/termux-api-package/pull/182

lvogt commented 7 months ago

I reread part of the AlarmManager documentation and made a few changes e584b5d and 06d680f

Any insights whether I got that right now are appreciated.

EDIT: Maybe switching to exact alarms as default is better approach anyway...

agnostic-apollo commented 7 months ago

Thanks for implementing this. Looks good and clean overall, but its too big to review or merge at this time by me, lot of things would need to be looked at in regards to android alarms and your cron design, not going to be possible before the next app updates.

lvogt commented 7 months ago

I understand, take your time.