androidandroid-management-apiandroid-managed-profile

Bluetooth scan and display devices not working when policy applied to device


I have an application that scans for Bluetooth device nearby and displays them on the app. This works fine when the phone is in normal mode, but when using android management API policy on the same phone, it does not show any result as before

Unable to understand what is causing this?

This is the policy that is being applied

policy_json = '''
{
  "applications": [
    {
      "packageName": "com.example.ble",
      "installType": "FORCE_INSTALLED"
    }
  ],    
  "debuggingFeaturesAllowed": true
}
'''

Thanks


Solution

  • Got a solution for the issue, there was no location mode specified so it was unable to get the location. the link to possible location modes is https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#LocationMode

    For some unspecified reason, location is required to scan for BLE devices

    The updated policy is

    policy_json = '''
    {
      "applications": [
        {
          "packageName": "com.example.ble",
          "installType": "FORCE_INSTALLED"
        }
      ],  
      "locationMode": "SENSORS_ONLY",
      "debuggingFeaturesAllowed": true
    }
    '''
    

    Hope this helps