Fairmatic

object Fairmatic

Fairmatic class is the entry point into the Fairmatic SDK. Other than setup, all methods are optional to call by the application. They are also no-ops in case setup has not been called. All methods are threadsafe.

Applications which want to record Fairmatic insurance periods for a driver may use this API. All drives (automatically detected or manually started) when a period is in progress will be tagged with the period id. This period id will be made available in the reports and API that Fairmatic provides via Fairmatic.

Only one period may be active at a time. To switch the Fairmatic insurance period, the application can call the relevant startPeriod method directly. Switching periods or calling stopPeriod stops any active drives (automatic or manual). A drive with multiple insurance periods will be split into multiple trips for different insurance periods.

Functions

Link copied to clipboard

Get info on the currently active drive. If sdk is not setup or if no drive is in progress, null is returned.

Link copied to clipboard

Returns an identifier which can be used to identify this SDK build.

Link copied to clipboard

Check whether the fairmatic event types are supported or not on this device

Link copied to clipboard
fun getFairmaticSettings(context: Context, fairmaticSettingsCallback: FairmaticSettingsCallback)

Get the current state of settings affecting the Fairmatic SDK's normal operation. If the SDK is set up, this async method returns a com.fairmatic.sdk.classes.FairmaticSettings object that contains a list of errors and warnings that are affecting Fairmatic's ability to detect trips and perform other tasks.

Link copied to clipboard

Is Fairmatic collision detection supported on this device?

Link copied to clipboard

Checks whether the string passed to the SDK is valid. String parameters cannot be null or empty. Unless documented otherwise, strings parameters to the SDK cannot contain any of the following characters - "?", " ", "&", "/", "\", ";", "#", "\n"

Link copied to clipboard
fun setFairmaticDriveDetectionMode(context: Context, fairmaticDriveDetectionMode: FairmaticDriveDetectionMode, fairmaticOperationCallback: FairmaticOperationCallback?)

Use this method to change the com.fairmatic.sdk.classes.FairmaticDriveDetectionMode after SDK is already setup. Applications which do not want the SDK to continuously track drives in background should set this value to AUTO_OFF. With this, the application needs to call startDrive method to record drives. In case the application wants to enable auto drive detection only for a fixed duration (like when the driver is on-duty), use this method to change the mode to AUTO_ON for that period and set it back to AUTO_OFF (once the driver goes off-duty). Once setup finishes, the com.fairmatic.sdk.classes.FairmaticOperationCallback is called (if provided) with the result of the setup operation. Callback will be made on calling thread if it's Looper is already prepared, else the callback is made on the Main Thread.

Link copied to clipboard
fun setup(context: Context, fairmaticConfiguration: FairmaticConfiguration, fairmaticBroadcastReceiver: Class<out FairmaticBroadcastReceiver?>?, fairmaticNotificationProvider: Class<out FairmaticNotificationProvider?>, fairmaticOperationCallback: FairmaticOperationCallback?)

Setup the Fairmatic SDK with a configuration and a intent service for SDK callbacks. This will start tracking the phone's movements to track any driving activity. The application should call this method before anything else in the Fairmatic SDK.

Link copied to clipboard
fun startDrive(context: Context, trackingId: String?, fairmaticOperationCallback: FairmaticOperationCallback?)

Manually start recording a drive. For applications which want to manually start recording drives this method may be called.

Link copied to clipboard

Start a drive in Fairmatic insurance period 1.

Link copied to clipboard
fun startDriveWithPeriod2(context: Context, trackingId: String, callback: FairmaticOperationCallback?)

Start Fairmatic insurance period 2 in the SDK. A manual trip with the given trackingId will be started immediately. The entire duration in this period will be recorded as a single trip. If period 2 is already in progress with the same trackingId, this call will be a no-op.

Link copied to clipboard
fun startDriveWithPeriod3(context: Context, trackingId: String, callback: FairmaticOperationCallback?)

Start Fairmatic insurance period 3 in the SDK. A manual trip with the given trackingId will be started immediately. The entire duration in this period will be recorded as a single trip. If period 3 is already in progress with the same trackingId, this call will be a no-op.

Link copied to clipboard

Start a session in the SDK. Applications which want to record several user's drives as a session may use this call. All drives (automatically detected or manually started) when a session is in progress will be tagged with the session id. If a drive is already on when this call is made, that drive will not belong to this session. This session id will be made available in the reports and API that Fairmatic provides.

Link copied to clipboard
fun stopManualDrive(context: Context, fairmaticOperationCallback: FairmaticOperationCallback?)

Stop the currently active manually started drive. The startDrive and stopManualDrive calls are not counted. i.e stopManualDrive will stop a manually started drive irrespective of how many times startDrive is called.

Link copied to clipboard

Stop currently ongoing Fairmatic insurance period if any. Ongoing trips will be stopped and auto trip detection is turned off.

Link copied to clipboard

Stop currently ongoing session. No-op if no session is ongoing. Trips that start after this call do not belong to the session. Ongoing trips at the time of this call will continue to belong to the session that was just stopped.

Link copied to clipboard
fun teardown(context: Context, fairmaticOperationCallback: FairmaticOperationCallback?)

Shuts down the Fairmatic framework. This may be called if the client code wishes to turn off the Fairmatic framework to isolate the operations that the application is doing. This is a no-op if setup has not been called.

Link copied to clipboard
fun triggerMockAccident(context: Context, fairmaticAccidentConfidence: FairmaticAccidentConfidence, fairmaticOperationCallback: FairmaticOperationCallback?)
fun triggerMockAccident(context: Context, accidentConfiguration: FairmaticMockAccidentConfiguration, fairmaticOperationCallback: FairmaticOperationCallback?)

Triggers a fake accident. A fake accident will be invoked on the FairmaticListener after this function is called. Requires that the Fairmatic SDK is setup and a trip is in progress.

Link copied to clipboard

Allows an application to trigger a bulk upload of all SDK data on the device to Fairmatic for debugging purposes. This uploads historical data and logs on the device. WARNING: This will cause significant battery drain on the device. It will also use significant upload bandwidth to upload this data.**

Link copied to clipboard
fun wipeOut(context: Context, fairmaticOperationCallback: FairmaticOperationCallback?)

Wipe out all the data that fairmatic keeps locally on the device. When Fairmatic SDK is torn down, trip data that is locally persisted continues to remain persisted. The data will be uploaded when SDK setup is called at a later time. Wipeout should be used when the application wants to remove all traces of Fairmatic on the device. Data cannot be recovered after this call.