Package org.opencabstandard.provider
Class HOSContract
- java.lang.Object
-
- org.opencabstandard.provider.HOSContract
-
public final class HOSContract extends java.lang.Object
Defines the contract for the OpenCab HOS Content provider. An OpenCab HOS provider app should define an AndroidContentProvider
class that follows this contract or should extend theAbstractHOSProvider
class and implement the abstract methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HOSContract.Clock
Object representing an HOS clock.static class
HOSContract.HOSStatus
An object representing the HOS status.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AUTHORITY
This authority is used for querying the HOS 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_HOS
Key for retrieving the HOS status from the returnedBundle
object.static java.lang.String
KEY_NAVIGATION_RESULT
For the methodsHOSContract
.METHOD_START_NAVIGATION andHOSContract
.METHOD_END_NAVIGATION, the returnedBundle
object will contain this key which maps to a Boolean indicating success or failure.static java.lang.String
METHOD_END_NAVIGATION
Provider method name indicating that the OpenCab consumer app has ended navigation.static java.lang.String
METHOD_GET_HOS
Provider method name for retrieving the current HOS.static java.lang.String
METHOD_START_NAVIGATION
Provider method name indicating that the OpenCab consumer app has started navigation.static java.lang.String
VERSION
This is the current version of the HOSContract for the Open Cab Standard.
-
Constructor Summary
Constructors Constructor Description HOSContract()
-
-
-
Field Detail
-
VERSION
public static final java.lang.String VERSION
This is the current version of the HOSContract for the Open Cab 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 when passed to the method calls.- See Also:
- Constant Field Values
-
AUTHORITY
public static final java.lang.String AUTHORITY
This authority is used for querying the HOS provider. This should be declared in the manifest as the authority for the HOS provider.- See Also:
- Constant Field Values
-
METHOD_GET_HOS
public static final java.lang.String METHOD_GET_HOS
Provider method name for retrieving the current HOS. The returned object contains a list of clocks. The clocks can be displayed in the OpenCab HOS consumer app to provide the driver update to date information about his current HOS status. This method can take some time to execute, so the consumer app should avoid making this call on the main thread as it could cause the app to become unresponsive.Example:
ContentResolver
resolver = getApplicationContext().getContentResolver();Bundle
result = resolver.call(Uri.parse("content://" +HOSContract
.AUTHORITY),HOSContract
.METHOD_GET_HOS,HOSContract
.VERSION, null);HOSContract
.HOSStatus status = result.getParcelableArrayList(HOSContract
.KEY_HOS);Diagram:
sequenceDiagram participant A as OpenCab Consumer participant B as OpenCab Provider A->>B: contentResolver.call(Uri.parse("content://org.opencabstandard.hos"), "getHOS", "0.2", null) B->>A: android.os.Bundle- See Also:
- Constant Field Values
-
METHOD_START_NAVIGATION
public static final java.lang.String METHOD_START_NAVIGATION
Provider method name indicating that the OpenCab consumer app has started navigation. The OpenCab provider app can use this as an indicator that it is not necessary to lock the screen due to vehicle motion.Example:
ContentResolver
resolver = getApplicationContext().getContentResolver();Bundle
result = resolver.call(Uri.parse("content://" +HOSContract
.AUTHORITY),HOSContract
.METHOD_START_NAVIGATION,HOSContract
.VERSION, null); Boolean status = result.getBoolean(HOSContract
.KEY_NAVIGATION_RESULT);Diagram:
sequenceDiagram participant A as OpenCab Consumer participant B as OpenCab Provider A->>B: contentResolver.call(Uri.parse("content://org.opencabstandard.hos"), "startNavigation", "0.2", null) B->>A: android.os.Bundle- See Also:
- Constant Field Values
-
METHOD_END_NAVIGATION
public static final java.lang.String METHOD_END_NAVIGATION
Provider method name indicating that the OpenCab consumer app has ended navigation. The OpenCab provider app can use this as an indicator that it can lock the screen due to vehicle motion.Example:
ContentResolver
resolver = getApplicationContext().getContentResolver();Bundle
result = resolver.call(Uri.parse("content://" +HOSContract
.AUTHORITY),HOSContract
.METHOD_END_NAVIGATION,HOSContract
.VERSION, null); Boolean status = result.getBoolean(HOSContract
.KEY_NAVIGATION_RESULT);Diagram:
sequenceDiagram participant A as OpenCab Consumer participant B as OpenCab Provider A->>B: contentResolver.call(Uri.parse("content://org.opencabstandard.hos"), "endNavigation", "0.2", null) B->>A: android.os.Bundle- See Also:
- Constant Field Values
-
KEY_HOS
public static final java.lang.String KEY_HOS
Key for retrieving the HOS status from the returnedBundle
object. If the value is null, an error occurred and you can then retrieve the error from theBundle
using the keyHOSContract
.KEY_ERROR.Example:
ContentResolver
resolver = getApplicationContext().getContentResolver();Bundle
result = resolver.call(Uri.parse("content://" +HOSContract
.AUTHORITY),HOSContract
.METHOD_GET_HOS,HOSContract
.VERSION, null);HOSContract.HOSStatus
status = result.getParelableArrayList(HOSContract
.KEY_HOS);- 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://" +HOSContract
.AUTHORITY), "ANY METHOD",HOSContract
.VERSION, null); String error = result.getString(HOSContract
.KEY_ERROR);- See Also:
- Constant Field Values
-
KEY_NAVIGATION_RESULT
public static final java.lang.String KEY_NAVIGATION_RESULT
For the methodsHOSContract
.METHOD_START_NAVIGATION andHOSContract
.METHOD_END_NAVIGATION, the returnedBundle
object will contain this key which maps to a Boolean indicating success or failure.Example:
Bundle
result = provider.call(Uri.parse("content://" +HOSContract
.AUTHORITY),HOSContract
.METHOD_START_NAVIGATION,HOSContract
.VERSION, null); Boolean status = result.getBoolean(HOSContract
.KEY_NAVIGATION_RESULT);- See Also:
- Constant Field Values
-
-