Closed g2flyer closed 6 years ago
This is expected. Starting from Oreo, you have to use:
adb shell am start-foreground-service -a com.orgzly.intent.action.SYNC_START com.orgzly/com.orgzly.android.sync.SyncService
(start-foreground-service
instead of startservice
)
I haven't tried Automate, I don't know what would be the equivalent. Let me know if you don't find anything, I'll check what can be done (perhaps a new Broadcast receiver).
@nevenz thanks for the super-quick reply. While it was successfully running with Oreo before April, I guess you raised only recently the targeted API level to 26/oreo ? (or maybe it was only the april security update which adds corresponding enforcement of this only now?)
In any case, I checked Automate docu and searched their forum, but couldn't find a way on how to start foreground services. That said, hopefully somebody will reply to my corresponding forum post and shed some light on how to do that with automate (which is otherwise a quite nice way to automate tasks ..)
@nevenz , I could figure out a workaround in Automate: there is also a catch-all shell-command flow block and with that it worked with above am command (after adding option '--user 0'). For more info on Automate aspect of issue, see discussion in automate forum. Thanks for your help (and also lots of thanks for developing orgzly!)
Cool.
I'll still add a new broadcast receiver to act as a proxy for starting the service to have a clean interface, and also as a generic receiver for different actions in the future (part of #299):
adb shell am broadcast -a com.orgzly.intent.action.SYNC_START com.orgzly/.android.ActionReceiver
Following claiire's comment on May 29, 2017 on issue #8 , i had set up an auto-sync of a dropbox repo and was using it successfully for quite some time. Alas, i just realized that since 2018-04-08, it fails to work as the attempt to sync by Automate gets following exception on a nexus 6p running android 8.1 (but not on a samsung table running android 7.1!):
java.lang.IllegalStateException: Not allowed to start service Intent { act=com.orglzly.intent.action.SYNC_START cmp=com.orgzly/.android.sync.SyncService }; app is in background uid null
I notice that seems to correspond recent changes regarding oreo and sync, but also was shortly after the april security update of android 8.1.
Caveat: claire's comment was for tasker and i just "transcribed" it to automate with a service start of package=com.orgzly/service class=com.orgzly.android.sync.SyncService/Action=com.orgzly.intent.action.SYNC_START. I notice now that the tasker rule also specifed '--user 0' whereas for automate i didn't see a place to add a user id. Maybe this could be related? The additional curious thing i've noticed is that i actually originally i had a typo in the Action (com.orglzly.intent.action.SYNC_START vs com.orgzly.intent.action.SYNC_START) yet it did work earlier (and still works on android 7.1). Fixing the typo, though didn't make any difference on android 8.1....