Class TelematicsSDK

java.lang.Object
com.sentilant.telematicssdk.TelematicsSDK
All Implemented Interfaces:
TelematicsSDKInterface

public class TelematicsSDK extends Object implements TelematicsSDKInterface
The core class of the Telematics SDK responsible for initializing the SDK, managing user and vehicle data, starting and stopping the telematics service, and handling permissions.
  • Method Details

    • getInstance

      public static TelematicsSDK getInstance(android.content.Context context)
      Returns the singleton instance of the Telematics SDK.
      Parameters:
      context - the application context used for initializing the SDK.
      Returns:
      the singleton instance of the Telematics SDK.
    • getEstimatedMileage

      public double getEstimatedMileage()
      Description copied from interface: TelematicsSDKInterface
      Retrieves the estimated current mileage for the vehicle in kilometers.

      This method returns the estimated mileage based on the data collected by the telematics service. If the telematics service is not running or insufficient data is available, it will return -1 to indicate that mileage estimation is not possible.

      Specified by:
      getEstimatedMileage in interface TelematicsSDKInterface
      Returns:
      The estimated mileage in kilometers as a double; returns -1 if estimation is not possible.
    • getMetricsSummary

      public void getMetricsSummary(String startDate, String endDate, TelematicsMetricsSummaryCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Retrieves a summary of metrics for the specified date range.
      Specified by:
      getMetricsSummary in interface TelematicsSDKInterface
      Parameters:
      startDate - The start date for retrieving metrics in the format "YYYY-MM-DDTHH:mm:ssZ" (ISO 8601 with timezone).
      endDate - The end date for retrieving metrics in the format "YYYY-MM-DDTHH:mm:ssZ" (ISO 8601 with timezone).
      callback - The callback to handle the metrics summary retrieval.
    • getLastTelematicsPeriodMetricsSummary

      public void getLastTelematicsPeriodMetricsSummary(TelematicsMetricsSummaryCallback callback)
      Specified by:
      getLastTelematicsPeriodMetricsSummary in interface TelematicsSDKInterface
    • getLastTelematicsDayMetricsSummary

      public void getLastTelematicsDayMetricsSummary(TelematicsMetricsSummaryCallback callback)
      Specified by:
      getLastTelematicsDayMetricsSummary in interface TelematicsSDKInterface
    • getChallenges

      public void getChallenges(boolean isGroupChallenges, TelematicsChallengesCallback callback)
      Specified by:
      getChallenges in interface TelematicsSDKInterface
    • getChallengeMetrics

      public void getChallengeMetrics(int challengeId, TelematicsChallengeMetricsCallback callback)
      Specified by:
      getChallengeMetrics in interface TelematicsSDKInterface
    • getChallengeGroupsRanking

      public void getChallengeGroupsRanking(int challengeId, TelematicsChallengeGroupsRankingCallback callback)
      Specified by:
      getChallengeGroupsRanking in interface TelematicsSDKInterface
    • insertManualEvent

      public void insertManualEvent(TelematicsManualEventType eventType)
      Specified by:
      insertManualEvent in interface TelematicsSDKInterface
    • getTrips

      public void getTrips(String startDate, String endDate, TelematicsTripsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Retrieves a list of trips within the specified date range.
      Specified by:
      getTrips in interface TelematicsSDKInterface
      Parameters:
      startDate - The start date for filtering trips in the format "YYYY-MM-DDTHH:mm:ssZ" (ISO 8601 with timezone).
      endDate - The end date for filtering trips in the format "YYYY-MM-DDTHH:mm:ssZ" (ISO 8601 with timezone).
      callback - The callback interface to handle the response. - If successful, the TelematicsTripsCallback.onTelematicsTripsFetched(List<TelematicsTripResume>) method will be called with the list of trips. - If there is an error, the TelematicsTripsCallback.onError(TelematicsSDKException) method will be called with the error information.
    • getFormTemplateByReference

      public void getFormTemplateByReference(String reference, TelematicsFormTemplateCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Retrieves a form template by its reference.
      Specified by:
      getFormTemplateByReference in interface TelematicsSDKInterface
      Parameters:
      reference - The unique reference identifier for the form template.
      callback - The callback to handle the form template retrieval.
    • getRequiredFormTemplates

      public void getRequiredFormTemplates(TelematicsFormTemplateCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Retrieves a list of required form templates.
      Specified by:
      getRequiredFormTemplates in interface TelematicsSDKInterface
      Parameters:
      callback - The callback to handle the retrieval of required form templates.
    • saveFormTemplates

      public void saveFormTemplates(List<TelematicsFormTemplateItemResponse> telematicsFormTemplateItemResponses, TelematicsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Saves the responses to form templates.
      Specified by:
      saveFormTemplates in interface TelematicsSDKInterface
      Parameters:
      telematicsFormTemplateItemResponses - A list of form template item responses to be saved.
      callback - The callback to handle the success or failure of the save operation.
    • getTrip

      public void getTrip(long id, TelematicsTripCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Retrieves the details of a specific trip by its unique ID.
      Specified by:
      getTrip in interface TelematicsSDKInterface
      Parameters:
      id - The unique identifier of the trip you want to retrieve.
      callback - The callback interface to handle the response. - If successful, the TelematicsTripCallback.onTelematicsTripFetched(TelematicsTripDetail) method will be called with the trip details. - If there is an error, the TelematicsTripCallback.onError(TelematicsSDKException) method will be called with the error information.
    • initSDK

      public void initSDK(String client, String clientId, String clientSecret, boolean isStaging, TelematicsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Initializes the Telematics SDK with the provided credentials and environment.
      Specified by:
      initSDK in interface TelematicsSDKInterface
      Parameters:
      client - The client name provided for authentication.
      clientId - The client ID provided for authentication.
      clientSecret - The client secret provided for authentication.
      isStaging - true to use the staging environment; false to use the production environment.
      callback - The callback to handle the success or failure of the initialization process.
    • initSDK

      public void initSDK(String clientId, String clientSecret, boolean isStaging, TelematicsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Initializes the Telematics SDK with the provided credentials and environment.
      Specified by:
      initSDK in interface TelematicsSDKInterface
      Parameters:
      clientId - The client ID provided for authentication.
      clientSecret - The client secret provided for authentication.
      isStaging - true to use the staging environment; false to use the production environment.
      callback - The callback to handle the success or failure of the initialization process.
    • getFuelTypes

      public void getFuelTypes(FuelTypesCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Asynchronously retrieves a map of fuel types supported by the SDK.

      The resulting map, where each key is the fuel type name and the corresponding value is its identifier code, is delivered via the provided FuelTypesCallback.

      Specified by:
      getFuelTypes in interface TelematicsSDKInterface
      Parameters:
      callback - the callback that will receive the fuel types map on success or an error if retrieval fails.
    • getVehicleTypes

      public void getVehicleTypes(VehicleTypesCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Asynchronously retrieves a map of vehicle types supported by the SDK.

      The resulting map, where each key is the vehicle type name and the corresponding value is its identifier code, is delivered via the provided VehicleTypesCallback.

      Specified by:
      getVehicleTypes in interface TelematicsSDKInterface
      Parameters:
      callback - the callback that will receive the vehicle types map on success or an error if retrieval fails.
    • getAddVehicleReasons

      public void getAddVehicleReasons(AddVehicleReasonsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Asynchronously retrieves a map of vehicle add reasons supported by the SDK.

      The resulting map, where each key is the vehicle add reason name and the corresponding value is its identifier code, is delivered via the provided AddVehicleReasonsCallback.

      Specified by:
      getAddVehicleReasons in interface TelematicsSDKInterface
      Parameters:
      callback - the callback that will receive the vehicle add reasons map on success or an error if retrieval fails.
    • getRequiredPermissions

      public String[] getRequiredPermissions()
      Description copied from interface: TelematicsSDKInterface
      Returns an array of Android permissions required by the SDK to function correctly.
      Specified by:
      getRequiredPermissions in interface TelematicsSDKInterface
      Returns:
      An array of required permission strings (e.g., android.Manifest.permission.ACCESS_FINE_LOCATION).
    • checkPermissions

      public List<String> checkPermissions()
      Description copied from interface: TelematicsSDKInterface
      Checks the current permissions and returns a list of permissions that are not granted.
      Specified by:
      checkPermissions in interface TelematicsSDKInterface
      Returns:
      A list of missing permission strings that are required by the SDK but not granted.
    • login

      public void login(String id, String extraID, String group, String serviceId, TelematicsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Logs in a user with the provided credentials and group information.
      Specified by:
      login in interface TelematicsSDKInterface
      Parameters:
      id - The unique identifier for the user.
      extraID - An additional user identifier, if applicable.
      group - The group code or name the user belongs to.
      serviceId - The service ID associated with the user.
      callback - The callback to handle the success or failure of the login process.
    • setVehicle

      public void setVehicle(String plate, String internalPlate, int type, int addReason, int fuelType, TelematicsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Sets the vehicle information with the specified details.
      Specified by:
      setVehicle in interface TelematicsSDKInterface
      Parameters:
      plate - The vehicle's license plate number.
      internalPlate - An internal identifier or secondary plate for the vehicle.
      type - The vehicle type identifier code (as returned by TelematicsSDKInterface.getVehicleTypes(VehicleTypesCallback)).
      addReason - The reason identifier code for adding the vehicle (as returned by TelematicsSDKInterface.getAddVehicleReasons(AddVehicleReasonsCallback)).
      fuelType - The fuel type identifier code (as returned by TelematicsSDKInterface.getFuelTypes(FuelTypesCallback)).
      callback - The callback to handle the success or failure of setting the vehicle information.
    • setVehicle

      public void setVehicle(String plate, TelematicsVehicleDetailsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Sets the current vehicle by its license plate.

      This method attempts to retrieve the vehicle associated with the provided license plate. If the vehicle exists, its details will be returned through the given callback. If the vehicle is not found, the callback will receive an appropriate error.

      Specified by:
      setVehicle in interface TelematicsSDKInterface
      Parameters:
      plate - The license plate number of the vehicle to be set.
      callback - The callback used to return the vehicle details if found, or an error if not.
    • getCurrentVehicleInfo

      public void getCurrentVehicleInfo(TelematicsVehicleDetailsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Retrieves the details of the currently selected vehicle.

      The current vehicle information is provided asynchronously through the supplied callback. If no vehicle has been set, the callback will return an error.

      Specified by:
      getCurrentVehicleInfo in interface TelematicsSDKInterface
      Parameters:
      callback - The callback used to return the current vehicle details or an error if unavailable.
    • clearVehicle

      public void clearVehicle()
      Description copied from interface: TelematicsSDKInterface
      Clears the current vehicle information from the SDK.
      Specified by:
      clearVehicle in interface TelematicsSDKInterface
    • setServiceCode

      public void setServiceCode(String serviceCode, TelematicsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Sets the service code for the telematics service.
      Specified by:
      setServiceCode in interface TelematicsSDKInterface
      Parameters:
      serviceCode - The service code to be used by the telematics service.
      callback - The callback to handle the success or failure of setting the service code.
    • isTelematicsServiceRunning

      public boolean isTelematicsServiceRunning()
      Description copied from interface: TelematicsSDKInterface
      Checks if the telematics service is currently running.
      Specified by:
      isTelematicsServiceRunning in interface TelematicsSDKInterface
      Returns:
      true if the telematics service is running; false otherwise.
    • logout

      public void logout()
      Description copied from interface: TelematicsSDKInterface
      Logs out the current user and stops the telematics service.
      Specified by:
      logout in interface TelematicsSDKInterface
    • getCurrentVehicleInfo

      public void getCurrentVehicleInfo(TelematicsVehicleCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Retrieves the current vehicle information and provides it via the callback.
      Specified by:
      getCurrentVehicleInfo in interface TelematicsSDKInterface
      Parameters:
      callback - The callback to receive the current vehicle information.
    • getCurrentUserInfo

      public void getCurrentUserInfo(TelematicsUserDetailsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Retrieves the current telematics user information and provides it asynchronously via the given TelematicsUserDetailsCallback.

      Use this variant when you need access to the full TelematicsUserDetails object, including fields such as id, name, group, and nickname.

      Specified by:
      getCurrentUserInfo in interface TelematicsSDKInterface
      Parameters:
      callback - the callback that will receive the detailed user information or an error if the retrieval fails
    • getCurrentUserInfo

      public void getCurrentUserInfo(TelematicsUserCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Retrieves the current user information and provides it via the callback.
      Specified by:
      getCurrentUserInfo in interface TelematicsSDKInterface
      Parameters:
      callback - The callback to receive the current user information.
    • startTelematicsService

      public void startTelematicsService(TelematicsServiceOptions options, TelematicsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Starts the telematics service with the specified options.

      This method allows providing a TelematicsServiceOptions instance to configure the behavior of the telematics service startup. The callback is used to notify whether the service was successfully started or if an error occurred.

      Specified by:
      startTelematicsService in interface TelematicsSDKInterface
      Parameters:
      options - the options to configure how the telematics service should be started; must not be null.
      callback - the callback to handle the success or failure of starting the telematics service; must not be null.
    • startTelematicsService

      public void startTelematicsService(String reason, String observations, TelematicsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Starts the telematics service if the required user and vehicle information is available.

      This method validates that all necessary user and vehicle details are provided before initiating the telematics service. It logs the specified reason and any additional observations for auditing or troubleshooting purposes. The provided callback is then used to notify the caller whether the service was successfully started or if an error occurred.

      Specified by:
      startTelematicsService in interface TelematicsSDKInterface
      Parameters:
      reason - the reason for starting the telematics service, used for logging or auditing purposes; can be null or empty.
      observations - additional observations or comments related to starting the telematics service; may be an empty string if no extra information is available.
      callback - the callback to handle the success or failure of starting the telematics service;
    • stopTelematicsService

      public void stopTelematicsService(TelematicsServiceOptions options, TelematicsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Stops the telematics service with the specified options.

      This method allows providing a TelematicsServiceOptions instance to configure the behavior of the telematics service shutdown. The callback is used to notify whether the service was successfully stopped or if an error occurred.

      Specified by:
      stopTelematicsService in interface TelematicsSDKInterface
      Parameters:
      options - the options to configure how the telematics service should be stopped; must not be null.
      callback - the callback to handle the success or failure of stopping the telematics service; must not be null.
    • stopTelematicsService

      public void stopTelematicsService(TelematicsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Stops the telematics service.
      Specified by:
      stopTelematicsService in interface TelematicsSDKInterface
      Parameters:
      callback - The callback to handle the success or failure of stopping the telematics service.
    • isBatteryOptimizationDeactivated

      public boolean isBatteryOptimizationDeactivated()
      Description copied from interface: TelematicsSDKInterface
      Checks if battery optimization is disabled for the application, which is required for accurate tracking.
      Specified by:
      isBatteryOptimizationDeactivated in interface TelematicsSDKInterface
      Returns:
      true if battery optimization is disabled for the app; false otherwise.
    • correctKilometers

      public void correctKilometers(int kilometers, String observations, int correctionCount, TelematicsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Corrects the odometer reading for the vehicle by applying the given value to a specified number of past records.
      Specified by:
      correctKilometers in interface TelematicsSDKInterface
      Parameters:
      kilometers - The corrected odometer reading in kilometers.
      observations - Any observations or comments related to the correction.
      correctionCount - The number of past records to which the correction should be applied.
      callback - The callback to handle the success or failure of the correction operation.
    • reportKilometers

      public void reportKilometers(int kilometers, String observations, TelematicsCallback callback)
      Description copied from interface: TelematicsSDKInterface
      Reports the current odometer reading for the vehicle.
      Specified by:
      reportKilometers in interface TelematicsSDKInterface
      Parameters:
      kilometers - The current odometer reading in kilometers.
      observations - Any observations or comments to include with the report.
      callback - The callback to handle the success or failure of the reporting operation.