The Android Management API doesn't offer to enable/disable Bluetooth directly at the moment.
However you can implement a companion app that controls the Bluetooth state through BluetoothAdapter
enable()
and disable()
methods. To do so:
- Create an Android app (the "companion" app) and upload it to Play (possibly as a private app)
- Set a policy to force install this app, grant it all permissions (so it gets the permission
android.permission.BLUETOOTH_ADMIN
) and launch it during setup:
{
"applications": [
{
"packageName": "com.example.companion",
"installType": "REQUIRE_FOR_SETUP",
"defaultPermissionPolicy": "GRANT"
}
],
"setupActions":[
{
"launchApp":{
"packageName":"com.example.companion"
}
}
]
}
- When the companion app launches call
BluetoothAdapter
enable()
or disable()
as needed
- (Optional) Implement managed configurations in the companion app to be able to configure it from the Android Management API via
ApplicationPolicy.managedConfiguration
.
You can also use the companion app for additional purposes if needed. Common use cases include: status page for your service, debug interface for admins, etc.