com.sonyericsson.extras.liveware.aef.registration
Class Registration

java.lang.Object
  extended by com.sonyericsson.extras.liveware.aef.registration.Registration

public class Registration
extends java.lang.Object

The Registration and Capability API is a part of the Smart Extension API's

This API is used by accessory extensions and accessory host applications. Typically host applications insert and maintain information about the accessories capabilities. Extensions use the capability information in order to interact with the accessories in a correct way. Before an extension can interact with an accessory it must provide (register) some information needed by the host applications. The API defines and implements an Android ContentProvider that applications access via the Android ContentResolver API. The ContentProvider implementation is backed by a database implementation.

Topics covered here:

  1. Extension registration
  2. Using the capabilities API
  3. Security.

Extension registration

Before an extension can use an accessory, the extension must use the registration API content provider to insert a record in the extension table. The URI is defined in the Extension interface Registration.Extension.URI and the table scheme is defined in the ExtensionColumns interface Registration.ExtensionColumns. After inserting a record in the extensions table, the extension is ready to use the Notification API. No further registration is needed in order to use the Notification API and start writing sources and events. More advanced extensions that also want to use any of the Widget API, Control API or Sensor API must also register information in the registration table. This should be done for each host application that the extension wants to interact with. In order to find out what host applications are available and what capabilities they support, the extension should use the capability API Using the capability API. The URI of the registration table is defined in the ApiRegistration interface Registration.ApiRegistration.URI and the table schema is defined in the ApiRegistrationColumns interface Registration.ApiRegistrationColumns. The extension should provide the host application package name and indicate what APIs it will use.

Using the capabilities API

This API is an Android content provider that provides information about the capabilities of the accessories. The information is provided by the host applications and are used by the extensions to obtain necessary information in order to interact with the accessories through the Control, Sensor and Widget APIs. The content provider contains the tables shown in the picture below. Operating context For each accessory there is a corresponding record in the host_application table. A Particular host application is identified by its package name. For each host application there is one or more device records in the device table. A particular device can support zero or more displays, sensors, leds and inputs, defined in the display, sensor, led and input tables respectively There is a sensor_type table describing each type of sensor and keypad table describing the capabilities if the keypads of each input type. The capabilities tables are accessible through the content provider.

Capability URI's and description

  1. Host application URI Registration.HostApp.URI and columns Registration.HostAppColumns
  2. Host application URI Registration.Device.URI and columns Registration.DeviceColumns
  3. Host application URI Registration.Display.URI and columns Registration.DisplayColumns
  4. Host application URI Registration.Sensor.URI and columns Registration.SensorColumns
  5. Host application URI Registration.Input.URI and columns Registration.InputColumns
  6. Host application URI Registration.Led.URI and columns Registration.LedColumns
  7. Host application URI Registration.SensorType.URI and columns Registration.SensorTypeColumns
  8. Host application URI Registration.KeyPad.URI and columns Registration.KeyPadColumns
It is also possible to use a view that returns all capabilities in a single query. The URI is Registration.Capabilities.URI.

*

Security

Each extension that which to interact with the Registration & Capabilities API should specify a specific plug-in permission in their manifest file EXTENSION_PERMISSION. The API implements a security mechanism that ensure that each extension only can access their own registration and notification data. Sharing information between extensions can be obtained for extensions that use the sharedUserId mechanism, however this approach is not recommended. Extensions do not have permission to write data in the capability tables, only host applications have write access.

Android Intents are sent when interaction with the extension is needed. See the documentation of the Control API, Widget API, Sensor API and Notification API for more information about intents. To enable the extension to verify the sender of the Intents is a trusted application with access to the APIs and not a malicious application that sends the same Intents on pretext of being a trusted application, the Registration.ExtensionColumns.EXTENSION_KEY field allows plug-in developers to store something that can be used as identification when the Intents are received. Except where android.app.Activity#startActivity(android.content.Intent) is used, this key is attached to every Intent the different accessory host applications send to the extension as these applications are granted access to the accessory information. The receiving extension should check the value of the key to see if it matches what it has. If not, the plug-in should ignore the Intent. This key is generated by the extension itself. It should be as unique as possible to minimize the risk of several extensions having the key. An extension is free to change the key stored in the database that it owns. As an added precaution, Intents are sent as directed Intents where possible.


Nested Class Summary
static interface Registration.AccessoryConnectionStatus
          Interface used to define constants for accessory connection status
static interface Registration.ApiRegistration
          Definitions used for interacting with the ApiRegistration-table
static interface Registration.ApiRegistrationColumns
          Column-definitions for the ApiRegistration-table
static interface Registration.Capabilities
          Definitions used for interacting with the Capabilities-view
static interface Registration.Device
          Definitions used for interacting with the Device-table
static interface Registration.DeviceColumns
          Column-definitions for the Device table
static interface Registration.Display
          Definitions used for interacting with the Display-table
static interface Registration.DisplayColumns
          Column-definitions for the Display table
static interface Registration.Extension
          Definitions used for interacting with the Extension-table
static interface Registration.ExtensionColumns
          Column-definitions for the Extension table
static interface Registration.HostApp
          Definitions used for interacting with the Host application-table
static interface Registration.HostAppColumns
          Column-definitions for the Host application table
static interface Registration.Input
          Definitions used for interacting with the Input-table
static interface Registration.InputColumns
          Column-definitions for the Sensor table
static interface Registration.Intents
          Broadcast Intents sent to extensions by the host applications
static interface Registration.KeyPad
          Definitions used for interacting with the Keypad-table
static interface Registration.KeyPadColumns
          Column-definitions for the Keypad table
static interface Registration.Led
          Definitions used for interacting with the Led-table
static interface Registration.LedColumns
          Column-definitions for the Led-table
static interface Registration.Sensor
          Definitions used for interacting with the Sensor-table
static interface Registration.SensorColumns
          Column-definitions for the Sensor table
static interface Registration.SensorType
          Definitions used for interacting with the Sensor-type-table
static interface Registration.SensorTypeColumns
          Column-definitions for the SensorType table
 
Field Summary
static java.lang.String AUTHORITY
          Authority for the Registration provider
protected static Uri BASE_URI
          Base URI for the Registration provider
static java.lang.String EXTENSION_PERMISSION
          All extensions should add in their AndroidManifest.xml a tag to use this permission.
static java.lang.String HOSTAPP_PERMISSION
          Permission used by host applications; Extensions shall use this permission to enforce security when sending intents to a host application using sendBroadcast(Intent, String)
 
Constructor Summary
protected Registration()
           
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXTENSION_PERMISSION

public static final java.lang.String EXTENSION_PERMISSION
All extensions should add in their AndroidManifest.xml a tag to use this permission. The purpose is to indicate to the end user the application containing the extension interacts with the registration API.

Since:
1.0
See Also:
Constant Field Values

HOSTAPP_PERMISSION

public static final java.lang.String HOSTAPP_PERMISSION
Permission used by host applications; Extensions shall use this permission to enforce security when sending intents to a host application using sendBroadcast(Intent, String)

Since:
1.0
See Also:
Constant Field Values

AUTHORITY

public static final java.lang.String AUTHORITY
Authority for the Registration provider

Since:
1.0
See Also:
Constant Field Values

BASE_URI

protected static final Uri BASE_URI
Base URI for the Registration provider

Since:
1.0
Constructor Detail

Registration

protected Registration()