Dear Android Devs:

What's the magic permissions set required to let BLE scans run in a foregrounded service while the screen is off (Currently on Android 12 but knowing how this works on <12 would be nice too)?

Yes I have battery optimizations turned off.

@buttplugio For android 12 and up, bluetooth_scan (and bluetooth_connect), for below you need access_fine_location, and bluetooth_admin... i think, have been spending some time with that the last few days - it's in Crumpet's manifest if you want a look (think you're in the chat?)

@leinir @buttplugio The base permissions are fine, comms work with screen on *or* off. This is *just* the case of:

- Start scan with screen on
- Turn screen off
- Have scan keep going

Right now the scan stops until the screen is turned on again.

Follow

@qdot @buttplugio hmmmm... that's foreground service stuff.. maybe you need to throw up the "i'm still alive" notification to let it remain awake, i think it gets paused otherwise (not actually sure for scanning, but it'd make sense...i only know i have to do that for the tail service to keep doing things while the display is off)

@qdot @buttplugio but yeah, maybe it just outright doesn't let you scan in the background like that... would seem a little odd, but maybe it's a "because user safety" type decision, like to stop people... wardriving bluetooth devices or something?

Sign in to participate in the conversation
Computer Fairies

Computer Fairies is a Mastodon instance that aims to be as queer, friendly and furry as possible. We welcome all kinds of computer fairies!