Automotive Location Bypass API

This feature allows location access of allowlisted, Android-bundled, driver assistance apps to be controlled separately by the “Use location for driver assistance” switch. This enables these apps to access location even when the "Use location" switch is off.

  • Android 12 doesn't provide a public API for this feature. Driver assistance apps should request location updates as usual.
  • Android 13 and higher must make a location request to use LocationManager.requestLocationUpdates() and pass in a LocationRequest object configured with LocationRequest.setAdasGnssBypass(true).

Use the driver assistance location bypass API

The following sections describe how to use the driver assistance location bypass API. To learn more about the usage policy, see Location Bypass Allowlist Policy.

Check the driver assistance switch status

In Android 13 and higher, you can check driver assistance switch status before requesting location updates.

// Returns the current status of "Use location for driver assistance".
locationManager.isAdasGnssLocationEnabled();

Run Android Debug Bridge (ADB) commands

For development and testing, you can quickly check or change the status of the driver assistance toggle without using Location Settings.

  1. To use ADB commands to check or change status:
    // Gets the status of ADAS location.
    adb shell cmd location is-adas-gnss-location-enabled
    
    // Enables ADAS location.
    adb shell cmd location set-adas-gnss-location-enabled true
    
    // Disables ADAS location.
    adb shell cmd location set-adas-gnss-location-enabled false
    

Set permission

See the following for version-specific Android releases:

  1. In Android 12, driver assistance apps must have the WRITE_SECURE_SETTINGS permission.
  2. In Android 13 and higher, the LOCATION_BYPASS permission is required.

Add an app to the allowlist on your device

In the etc/sysconfig directory:

  1. Add the app’s package name in a system configuration XML file:
  2. <!-- In a xml file under etc/sysconfig–>
    <config>
    …
    <allow-adas-location-settings package="PACKAGE-NAME" />
    …
    </config>
    

To ensure your package appears in the Location Settings UI, add your package name to config_locationDriverAssistancePackageNames.

Add the app’s URL of privacy policy disclosure to AndroidManifest.xml. The name of the meta-data should be privacy_policy.

<meta-data android:name="privacy_policy" android:value= privacy policy URL/>

Remove the "Use location for driver assistance switch"

If you don’t have a location-powered driver assistance app that requests location from Android, you can comment out the code block to remove the switch for Location Settings.

  1. Open packages/apps/Car/Settings/res/xml/location_settings_fragment.xml and then comment out the following code.
    <com.android.car.ui.preference.CarUiTwoActionSwitchPreference
    
        android:fragment="com.android.car.settings.location.AdasLocationFragment"
    
        android:key="@string/pk_location_driver_assistance_state_switch"
    
        android:title="@string/location_driver_assistance_toggle_title"
    
        android:summary="@string/location_driver_assistance_toggle_summary"
    
    
    settings:controller="com.android.car.settings.location.AdasLocationSwitchPreferenceController"
    
        settings:searchable="true"/>
    
      <com.android.car.settings.common.DividerPreference/>
    
  2. After removing the switch, set config_defaultAdasGnssLocationEnabled to false.

Run the Automotive test suite

Google provides an Automotive test suite (ATS) test, which ensures that all driver assistance packages on a device have been allowlisted with Google. The test is remotely configured. You needn't wait until the next ATS release to add a new package. You can learn more at Complete Automotive Tests in a Box.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2024-03-18 UTC.