Class VehicleInformationContract

java.lang.Object
org.opencabstandard.provider.VehicleInformationContract

public final class VehicleInformationContract extends Object
Defines the contract for the OpenCab Vehicle Information provider. An OpenCab Vehicle Information provider app should define an Android ContentProvider class that follows this contract or should subclass the AbstractVehicleInformationProvider class and implement the abstract methods.
sequenceDiagram participant A as OpenCab Consumer participant B as OpenCab Provider Note over A,B: consumer app launches, no driver logged in A->>+B: provider.call(METHOD_GET_VEHICLE_INFORMATION, version: 1) B->>A: {VEHICLE_INFORMATION: null} Note over A,B: driver logs in or connects to a vehicle mount B->>A: ACTION_VEHICLE_INFORMATION_CHANGED A->>+B: provider.call(METHOD_GET_VEHICLE_INFORMATION, version: 1) B->>A: {VEHICLE_INFORMATION: {VIN: "JH4NA1150RT000268", inGear: false}} Note over A,B: driver switches to D status or puts vehicle in gear B->>A: ACTION_VEHICLE_INFORMATION_CHANGED A->>+B: provider.call(METHOD_GET_VEHICLE_INFORMATION, version: 1) B->>A: {VEHICLE_INFORMATION: {VIN: "JH4NA1150RT000268", inGear: true}} Note over A,B: driver logs out or detaches tablet B->>A: ACTION_VEHICLE_INFORMATION_CHANGED A->>+B: provider.call(METHOD_GET_VEHICLE_INFORMATION, version: 1) B->>A: {VEHICLE_INFORMATION: null}
  • Field Details

    • VERSION

      public static final String VERSION
      This is the current version of the VehicleInformationContract for the OpenCab Standard. The version will be passed as an argument to all method calls to the provider. The provider may reject or handle appropriately if the VERSION does not match the expected value. An OpenCab vehicle information provider allows access to details about the vehicle, if any, associated with the mobile device running the app or associated with the driver who is logged into the mobile app.
      See Also:
    • AUTHORITY

      public static final String AUTHORITY
      This authority is declared in the manifest for the app that acts as the vehicle information provider. It is then used by the consumer app to identify any providers installed on the device.
      See Also:
    • VEHICLE_INFORMATION_CHANGED_RECEIVER

      public static final String VEHICLE_INFORMATION_CHANGED_RECEIVER
      This is the name of the receiver class. Application will be looking for classes with this name when it tries to broadcast an event.
      See Also:
    • ACTION_VEHICLE_INFORMATION_CHANGED

      public static final String ACTION_VEHICLE_INFORMATION_CHANGED
      This Action is broadcast when the vehicle information changes, perhaps because the driver chooses to associate with another vehicle, or if the device removed from a vehicle in a slip-seat scenario.
      See Also:
    • METHOD_GET_VEHICLE_INFORMATION

      public static final String METHOD_GET_VEHICLE_INFORMATION
      Provider method for retrieving the vehicle information.

      Example:

       
      
           ContentResolver resolver = getApplicationContext().getContentResolver();
           Bundle result = resolver.call(Uri.parse("content://" + VehicleInformationContract.AUTHORITY),
                                        VehicleInformationContract.METHOD_GET_VEHICLE_INFORMATION,
                                        VehicleInformationContract.VERSION,
                                        null);
           VehicleInformationContract.VehicleInformation info = result.getParcelableArrayList(VehicleInformationContract.KEY_VEHICLE_INFORMATION);
       
       
      See Also:
    • KEY_VEHICLE_INFORMATION

      public static final String KEY_VEHICLE_INFORMATION
      Use this key to retrieve the VIN from the Bundle object that is returned from the VehicleInformationContract.METHOD_GET_VEHICLE_INFORMATION method call. If the value is null, an error occurred and you can then retrieve the error from the Bundle using the key VehicleInformationContract.KEY_ERROR.

      Example:

       
      
           ContentResolver resolver = getApplicationContext().getContentResolver();
           Bundle result = resolver.call(Uri.parse("content://" + VehicleInformationContract.AUTHORITY),
                                        VehicleInformationContract.METHOD_GET_VEHICLE_INFORMATION,
                                        VehicleInformationContract.VERSION,
                                        null);
           VehicleInformationContract.VehicleInformation info = result.getParcelableArrayList(VehicleInformationContract.KEY_VEHICLE_INFORMATION);
       
       
      See Also:
    • KEY_ERROR

      public static final String KEY_ERROR
      If an error has occurred in one of the provider method calls, use this key to retrieve the error from the Bundle object returned from the provider call method.

      Example:

       
           Bundle result = provider.call(Uri.parse("content://" + VehicleInformationContract.AUTHORITY),
                                        "ANY METHOD",
                                        VehicleInformationContract.VERSION,
                                        null);
           String error = result.getString(VehicleInformationContract.KEY_ERROR);
       
       
      See Also:
    • KEY_VERSION

      public static final String KEY_VERSION
      For the methods VehicleInformationContract.METHOD_GET_VEHICLE_INFORMATION and VehicleInformationContract.METHOD_GET_VEHICLE_INFORMATION, the returned Bundle object will contain this key which maps to String indicating contract version supported.

      Example:

       
           ContentResolver resolver = getApplicationContext().getContentResolver();
           Bundle result = resolver.call(Uri.parse("content://" + HOSContract.AUTHORITY),
                                        VehicleInformationContract.METHOD_GET_LOGIN_CREDENTIALS,
                                        IdentityContract.VERSION,
                                        null);
           String version = result.getBoolean(IdentityContract.METHOD_GET_VEHICLE_INFORMATION);
       
       
      See Also:
  • Constructor Details

    • VehicleInformationContract

      public VehicleInformationContract()