Package org.opencabstandard.provider
Class VehicleInformationContract
- java.lang.Object
-
- org.opencabstandard.provider.VehicleInformationContract
-
public final class VehicleInformationContract extends java.lang.Object
Defines the contract for the OpenCab Vehicle Information provider. An OpenCab Vehicle Information provider app should define an AndroidContentProvider
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}
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
VehicleInformationContract.VehicleInformation
Object containing the vehicle information.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.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.static java.lang.String
AUTHORITY
This authority is declared in the manifest for the app that acts as the vehicle information provider.static java.lang.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.static java.lang.String
KEY_VEHICLE_INFORMATION
Use this key to retrieve the VIN from theBundle
object that is returned from theVehicleInformationContract
.METHOD_GET_VEHICLE_INFORMATION method call.static java.lang.String
KEY_VERSION
For the methodsVehicleInformationContract
.METHOD_GET_VEHICLE_INFORMATION andVehicleInformationContract
.METHOD_GET_VEHICLE_INFORMATION, the returnedBundle
object will contain this key which maps to String indicating contract version supported.static java.lang.String
METHOD_GET_VEHICLE_INFORMATION
Provider method for retrieving the vehicle information.static java.lang.String
VEHICLE_INFORMATION_CHANGED_RECEIVER
This is the name of the receiver class.static java.lang.String
VERSION
This is the current version of theVehicleInformationContract
for the OpenCab Standard.
-
Constructor Summary
Constructors Constructor Description VehicleInformationContract()
-
-
-
Field Detail
-
VERSION
public static final java.lang.String VERSION
This is the current version of theVehicleInformationContract
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:
- Constant Field Values
-
AUTHORITY
public static final java.lang.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:
- Constant Field Values
-
VEHICLE_INFORMATION_CHANGED_RECEIVER
public static final java.lang.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:
- Constant Field Values
-
ACTION_VEHICLE_INFORMATION_CHANGED
public static final java.lang.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:
- Constant Field Values
-
METHOD_GET_VEHICLE_INFORMATION
public static final java.lang.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:
- Constant Field Values
-
KEY_VEHICLE_INFORMATION
public static final java.lang.String KEY_VEHICLE_INFORMATION
Use this key to retrieve the VIN from theBundle
object that is returned from theVehicleInformationContract
.METHOD_GET_VEHICLE_INFORMATION method call. If the value is null, an error occurred and you can then retrieve the error from theBundle
using the keyVehicleInformationContract
.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:
- Constant Field Values
-
KEY_ERROR
public static final java.lang.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:
- Constant Field Values
-
KEY_VERSION
public static final java.lang.String KEY_VERSION
For the methodsVehicleInformationContract
.METHOD_GET_VEHICLE_INFORMATION andVehicleInformationContract
.METHOD_GET_VEHICLE_INFORMATION, the returnedBundle
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:
- Constant Field Values
-
-