Permissions

Each SDK component requires specific permissions to operate, and these are specified in each module's manifest file.

Trip Detection

Runtime Permissions

The following permissions must be listed in the manifest, and, in addition, the user must explicitly agree to grant these permissions.

Note that users can revoke any of these permissions at any time, so your app must check each time it runs instead of assuming that once granted they're always granted. You can see one way to request these permissions in the sample app.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

This is required to get the vehicle's location.

<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

The trip recorder normally runs while the phone is inactive (see Distracted Driving). The SDK needs special permission to keep running when Android would otherwise put the phone into a deep power saving mode. This permission asks the user to allow the app to ignore battery optimizations (that is, put them on the whitelist of apps shown by the Battery Optimization settings).

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

The phone state permission is required by the Distracted Driving module. The SDK uses it to determine if the user is making a phone call.

<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION"/>

The SDK makes use of "physical activity" for determining the start and end of trips.

The android.permission.ACTIVITY_RECOGNITION permission is required for targetSdkVersion=29 (Android 10) and above; the gms permission is used for older Android versions. We recommend using both versions in the manifest.

When targeting Android 10 and above you must also ask for the activity recognition permission at runtime. Revoking the "physical activity" permission impacts the SDK's ability to detect trips.

You can see an example of how to request these permissions in the sample app.

The ACCESS_COARSE_LOCATION, BLUETOOTH_SCAN and BLUETOOTH_CONNECT permissions are needed for Android 12 and later.

The SDK sets notification for detecting a potential trip and a confirmed trip. For that to be displayed on the phone the following is needed.

    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

For Android 13 and above you would need to add

<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

Runtime Permissions

The SDK determines the permissions required for the current configuration. This list can be obtained by querying the device manager:

DsDeviceManager.requiredPermissions

Support for any Bluetooth devices requires the BLUETOOTH and BLUETOOTH_ADMIN manifest permissions. These are considered "normal" level permissions, see permissions, and are automatically granted when added to the manifest.

The SDK automatically adds the required manifest permissions, but the app is responsible for obtaining runtime permissions.

The SDK sample (test) app has a full implementation of the code to handle the user interaction for device permissions.

Bluetooth Control Pseudo-Permissions

The SDK defines two "pseudo-permissions" used for Bluetooth operations.

  • DsBluetoothPermission.BLUETOOTH_ENABLED: Any attempt to use a Bluetooth device when Bluetooth is disabled returns this permission as part of the error status.

  • DsBluetoothPermission.BLUETOOTH_CONTROL: Permission for the SDK to control Bluetooth by turning it on and off as required. Android guidelines say that apps should never turn Bluetooth on or off without explicit user permission; if the app has obtained this permission it can inform the SDK and from there on the SDK will automatically turn Bluetooth on when required, and, if it was turned on by the SDK, turn it off when no longer required.

Bluetooth scan permissions

Some Bluetooth devices (e.g. wedge) require runtime permissions before they can be detected, whereas others (e.g. headset) do not. These are also treated as pseudo-permissions to simplify support for different versions of Android.

  • DsBluetoothPermission.BLUETOOTH_FOREGROUND: Required to detect nearby Bluetooth devices while the app is active or during trip recording. This corresponds to the ACCESS_FINE_LOCATION permission.

  • DsBluetoothPermission.BLUETOOTH_BACKGROUND: Required to detect nearby Bluetooth devices when the app is not active. In versions up to Android 11 this corresponds to the ACCESS_BACKGROUND_LOCATION permission.

  • DsBluetoothPermission.BLUETOOTH_SCAN: Required to detect nearby Bluetooth devices in Android 12 and later.

  • DsBluetoothPermission.BLUETOOTH_CONNECT: Required to detect and identify nearby Bluetooth devices in Android 12 and later.

Note that both location and background location permissions are also required for trip detection and recording, so most SDK apps will already have these permissions.

Full Set of Permissions

Here is the full set of permissions that could be used when targeting Android 12 (API 31) and later. Most of these permissions are required only when trip detection and recording is used; the specific permissions added depend on the SDK features you are using.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

Note that any permission added to the manifest is visible on the Play Store, even if it is not used.

Last updated