Closed hufman closed 1 year ago
This locks down in November 2022, at which time no updates to AAIdrive can be pushed without targeting API 31.
There's a few options, from reading the list of exemptions:
Any app that doesn't have Battery Optimization will support launching from background. There's even a handy Intent to go to the settings screen. I think there might already be verbiage about disabling battery optimizations, this can be brought forward if the OS is new enough and the battery optimizations are detected.
Receiving a BLUETOOTH_CONNECT broadcast allows the app to launch a foreground service from the background. A2DPBroadcastReceiver is currently configured to receive those broadcasts, and the Main UI would just need a permission checkbox to start automatically when the car connects over Bluetooth to request the BLUETOOTH_CONNECT permission.
The official proper way is to associate the app as a Companion Device for each specific car, with a much more involved UI flow:
An alternative method would be to add the special Activity Recognition library to start when the user goes In Vehicle.
When eventually Google Play Store requires that the app targets API 31, it will run into restrictions about starting the service in the background. There's a new (dangerous, so needs a prompt to request) Bluetooth permission to add and the service can be started from the Bluetooth event handler, but there may also need to be extra error handling in other service start places.