1.15.x -> 1.16
Upgrading to SDK 1.16
Breaking Changes
SDK Configuration
SDK 1.16 changes the way the SDK is configured and initialized.
In summary,
Once the SDK is configured it automatically initializes itself using Android Initializers. There is no longer any need to initialize the SDK during
Application.onCreate()
.The core SDK is controlled through the new
ImsSdkManager
usingImsSdkConfiguration
.The trip manager
DsTripManager
is replaced withImsTripManager
using the newImsTripConfiguration
.Trip manager configuration now uses explicit configuration for detectors, validators, and telemetry.
Other Changes
The scoring service no longer supports fetchDrivingSummaryAggregate
Migrating Your Code
Module Dependencies and Obfuscation
These changes apply only if your app is using Bluetooth devices
Remove the dependency on the "provider-devices" module. This module is no longer available; the functionality is now part of trip detection.
If you are using the IMS Wedge device, change the dependency on the "devices-ble-nordic" module to "devices-wedge".
If you are using distracted driving telemetry for trip recording, add the following additional line to the app's proguard-rules.pro:
The class name for your custom token signer must not be obfuscated (see below):
If you are using the trip recorder, then the name of the trip notification factory must not be obfuscated (see below):
SDK Configuration
Previous versions required the SDK to be configured and initialized during the Application.onCreate()
method.
The following shows typical code from SDK 1.15:
Most of that code is used to configure the SDK and trip manager. The SDK now saves its configuration and automatically initializes itself from that saved configuration; the only requirement is that you initialize the SDK before using it.
We recommend configuring the SDK using an Initializer
, such as with the SdkInitializer
class in the sample app, but you can still do this during Application.onCreate()
if desired.
The following 1.16 configuration code corresponds to the 1.15 version code above.
Note that some of the previous DsTripManager and DsHeartbeat methods have moved to ImsSdkConfiguration, and the trip manager configuration itself has changed.
The SDK no longer uses default detectors and validators when none are specified. If you were relying on the previous defaults you must now specify them explicitly.
Unless your app starts trip recording explicitly, you must specify at least one of GEOFENCE, ACTIVITY, and/or DEVICE, or else no trips will be recorded.
Unless your app stops trip recording explicitly, you must specify PHONE and/or DEVICE, or else no trips will be recorded.
1.15 Defaults | 1.16 Equivalent Parameters |
---|---|
No detectors specified | TripDetector.GEOFENCE, TripDetector.ACTIVITY |
No validators specified | TripValidator.PHONE |
The following section lists the old and new configuration parameters
1.15 | 1.16 | Description |
---|---|---|
(none) | ImsSdkManager.Builder setApiKey(String) | This is the API key used in the Identity class. |
initialize() Directories(folder) | ImsSdkManager.Builder setSdkFolder(File) | The folder where the SDK stores its files. We recommend that this folder be excluded from Auto Backup. |
initialize() tokenSignerFactory | ImsSdkManager.Builder setTokenSigner(Class) | Instead of passing a TokenSigner object, you pass the Class for the token signer. This will let the SDK create the class as required rather than requiring the app to initialize it every time. The token signer class must now have a no-parameter (empty) constructor. |
DsTripManager .setUploadWiFiOnly | ImsSdkManager.Builder -or- ImsSdkManager setUploadWifiOnly | The WiFi-only upload setting is now saved by the SDK and does not need to be set unless it changes |
DsHeartbeat .startHeartbeat | ImsSdkManager.Builder -or- ImsSdkManager setHeartbeatInterval | Set the heartbeat update interval in hours, or use 0 (default) to disable it. |
DsTripManager .initializeFileUploader (identityCallback) | ImsSdkManager.Builder -or- ImsSdkManager setIdentity | The previous requirement for the app to supply a |
DsTripManager setTripFeature FEATURE_GEOFENCE_MONITOR | ImsTripManager.Builder -or- ImsTripManager setTripDetectors TripDetector.GEOFENCE | Trip detectors are used to detect the possible start of a trip: geofence |
DsTripManager setTripFeature FEATURE_ACTIVITY_MONITOR | ImsTripManager.Builder -or- ImsTripManager setTripDetectors TripDetector.ACTIVITY | Trip detectors are used to detect the possible start of a trip: activity recognition |
DsTripManager setTripFeature FEATURE_AWARENESS_API_MONITOR | ImsTripManager.Builder -or- ImsTripManager setTripDetectors TripDetector.AWARENESS | Trip detectors are used to detect the possible start of a trip: awareness |
DsTripManager setTripFeature FEATURE_PHONE_VALIDATION | ImsTripManager.Builder -or- ImsTripManager setTripValidators TripValidator.PHONE | Trip validators are used to distinguish a valid trip from a false detection. The PHONE validator checks phone sensors such as location, speed, and activity. |
DsTripManager setTripFeature FEATURE_DEVICE_VALIDATION | ImsTripManager.Builder -or- ImsTripManager setTripValidators TripValidator.DEVICE | Trip validators are used to distinguish a valid trip from a false detection. The DEVICE validator verifies that the device is present during the trip. |
DsTripManager setTripTelemetry GPS | ImsTripManager.Builder -or- ImsTripManager setTripTelemetry LOCATION | The |
DsTripManager setTripTelemetry SPEED | ImsTripManager.Builder setTripTelemetry TripTelemetry.SPEED | |
DsTripManager addTripDetectors DsDeviceDetectionMonitor() | ImsTripManager.Builder -or- ImsTripManager setTripDetectors TripDetector.DEVICE | Device-based trip detection is now specified using the |
DsTripManager addTripProviders DsVehicleDetectionProvider() | ImsTripManager.Builder -or- ImsTripManager setTripTelemetry TripTelemetry .VERIFIED_VEHICLE | Identifying the vehicle associated to a device is now specified using the |
DsTripManager addTripProviders DistractedDrivingRecordProvider() | ImsTripConfiguration -or- ImsTripManager setTripTelemetry TripTelemetry .DISTRACTED_DRIVING | Distracted driving is now activated using the |
DsTripManager setTripNotification NotificationFactory() | ImsTripManager.Builder setTripNotification Class | The notification factory is specified by its class rather than an instance. Note that the |
The trip notification factory has changes to make the methods more explicit and to let the SDK create the class as required instead of requiring the app to initialize it every time.
Old TripNotificationFactory | New TripNotificationFactory |
---|---|
|
|
|
|
Constructor | Constructor |
Runtime Initialization
Depending on how you use the SDK, additional initialization may be required at runtime.
We recommend initializing the SDK using an Initializer
, such as with the SdkInitializer
class in the sample app, but you can still do this during Application.onCreate()
if desired.
For example, the SDK sample app sets up a local log recorder and specifies supported Bluetooth devices, then sets up a trip manager status listener.
In SDK 1.16 the log listener is set using ImsSdk.addLogListener()
and the trip manager listener through ImsTripManager.addTripStatusListener()
. Device initialization has not changed.
Last updated