pretix / pretixprint-android

Android printing driver app for pretixPOS and pretixSCAN
Other
6 stars 9 forks source link

Set a foreground service type (part of #72) #74

Closed raphaelm closed 9 months ago

raphaelm commented 9 months ago

I chose connectedDevice since it most closely matches the intended purpose:

Interactions with external devices that require a Bluetooth, NFC, IR, USB, or network connection.

Unfortunately, in situations where PRINT is not used for USB or Bluetooth, we do not satistfy the runtime permissions unless we request a useless permission… so let's request a useless permission :facepalm:

I tested this on an Android 14 device by temporarily setting the target SDK to Android 14. Without this PR, I received the following crash:

android.app.MissingForegroundServiceTypeException: Starting FGS without a type  callerApp=ProcessRecord{e25b32 22068:eu.pretix.pretixprint.debug/u0a517} targetSDK=34

With this PR, it worked.

I tried to "clean" the installation so it does not me ever having used USB or bluetooth with this app, but not sure how long it remembers ;) Still, this is in line with the docs, so should be fine.