Package org.opencabstandard.provider
Overview
An OpenCab provider is a mechanism for communicating between two Android apps running on the same device. One app will be the OpenCab provider app and will implement an Android ContentProvider that implements the appropriate Contract class. The second app will be the OpenCab consumer app and will make calls to the ContentProvider supplied by the provider app.The Contract and Abstract classes can be found here. You will want to add the relevant classes to your Android project.
For example, an app that will be an OpenCab Identity provider will contain a
ContentProvider
that implements the IdentityContract
. The OpenCab consumer app will
make calls to the
ContentProvider
supplied by the OpenCab provider app. In this example the consumer app may use the results from
ContentProvider
to SSO into the consumer app with credentials from the provider app.
To aid in implementing the
ContentProvider,
we have created abstract implementations that handle much of the work for you. For the Identity provider,
you may extend the AbstractIdentityProvider
class as follows:
public class MyIdentityProvider extends AbstractIdentityProvider {
@Override
public IdentityContract.LoginCredentials getLoginCredentials(String version) {
// Your logic goes here
}
@Override
public ArrayList<IdentityContract.Driver> getActiveDrivers(String version) {
// Your logic goes here
}
}
An example sequence might be like the following:
Security
The OpenCab provider app must declare the ContentProviders in the manifest with dual authorities. One authority must match the OpenCab AUTHORITY in the appropriate Contract class and the second should be unique to the provider application. The OpenCab consumer app will identify the ContentProvider based on the OpenCab AUTHORITY, but then will use the second authority to make the call to the ContentProvider.
An example of the ContentProvider declared in the manifest:
<provider android:authorities="org.opencabstandard.identity;com.myexample.identity"
android:exported="true"
android:label="identity"
android:name="com.myexample.IdentityContentProvider">
</provider>
The OpenCab consumer app must register the OpenCab authorities as queries in the Android manifest as follows:
<queries>
<provider android:authorities="org.opencabstandard.hos" />
<provider android:authorities="org.opencabstandard.identity" />
</queries>
-
Class Summary Class Description AbstractHOSProvider An abstract ContentProvider that implements theHOSContract
.AbstractIdentityProvider An abstract ContentProvider that implements theIdentityContract
.AbstractVehicleInformationProvider An abstract ContentProvider that implements theVehicleInformationContract
.HOSContract Defines the contract for the OpenCab HOS Content provider.HOSContract.Clock Object representing an HOS clock.HOSContract.HOSStatus An object representing the HOS status.IdentityContract Defines the contract for the OpenCab Identity Content provider.IdentityContract.Driver Object representing a Driver.IdentityContract.LoginCredentials Object containing the login credentials.VehicleInformationContract Defines the contract for the OpenCab Vehicle Information provider.VehicleInformationContract.VehicleInformation Object containing the vehicle information. -
Enum Summary Enum Description HOSContract.Clock.ValueType Allowed types for valueType field.