Skip to content

DataSourceClient

DriveMotion provides DataSource related functions. To use these functions, you must first obtain an instance of DataSourceClient.

Get DataSourceClient

1
2
3
4
5
    try {
        DataSourceClient dataSourceClient = DriveMotionService.getDataSourceClient();
    } catch (DriveMotionException e) {
        // The SDK is not initialized
    }
1
2
3
4
5
    try {
        val dataSourceClient: DataSourceClient = DriveMotionService.getDataSourceClient()
    } catch (e: DriveMotionException) {
        // The SDK is not initialized
    }

Use DataSourceClient

DataSourceClient allows the external application feed Location info and Road info to. These operations are only take effects when the SDK is initialized with "DriveMotionSettings.withUseExternalDataSource(true)".

Send Location Information

The sendLocation method allow external application feed SDK new updated location info instead of using Android native's LocationManager.

1
    dataSourceClient.sendLocation(Location);
1
    dataSourceClient.sendLocation(Location)

Send Road Information

The sendRoadInfo method will update SDK with new road info, the unit of speed_limit in RoadInfoItem is meters per second.

1
    dataSourceClient.sendRoadInfo(RoadInfoItem);
1
    dataSourceClient.sendRoadInfo(RoadInfoItem)

Set default speed limit

The setDefaultSpeedLimit method will set a default speed limit when can't fetch any valid road info, the unit of defaultSpeedLimit is meters per second. The valid defaultSpeedLimit should be null or positive double value. Positive value means the default speed limit, null means reset and use SDK speed limit. 0 or negative value will be rejected and return false.

1
    boolean result = dataSourceClient.setDefaultSpeedLimit(Double defaultSpeedLimit);
1
    val result = dataSourceClient.setDefaultSpeedLimit(defaultSpeedLimit: Double)

Set Default Speed Offset (Since 2.0 and using for replace setDefaultSpeedLimit)

DriveMotion SDK support setDefaultSpeedLimit(speedLimitInMPS) in release 1.4 which can used to modify the default speed limit for speeding detect when can't get valid road info with speed limit value. In DriveMotion 2.0, this feature can be replaced by the newly provided setSpeedLimitOffset(isPersist, offests) method for more precise and dynamic control.

1
    boolean result = dataSourceClient.setSpeedLimitOffset(Boolean isPersist, Map<RoadClassification, Double> offsets);
1
    val result = dataSourceClient.setSpeedLimitOffset(isPersist, offsets: Map<RoadClassification, Double>)

Use DataSourceClient for Bluetooth Call on Head Unit

As the bluetooth phone call status on head unit cannot be obtained by SDK, these two interfaces are provided to passing the phone call status to SDK by external app/launcher.

Make phone call / Answer the call

1
    dataSourceClient.onCallStart();
1
    dataSourceClient.onCallStart()

Hang up the phone

1
    dataSourceClient.onCallEnd();
1
    dataSourceClient.onCallEnd()