All Google TV devices can connect with remote devices unless the user selects to disable it with
> Language & input devices > Manage IP remotes > Connect to new IP remotes.
To communicate with Google TV, a remote application does the following:
- Identifies ("discovers") a Google TV device.
- Authenticates itself with the Google TV device.
- Sends events to the Google TV device (this is where the work of the application happens).
The Google TV implementation of the Anymote Protocol requires that remote devices connect using TLS/SSL, which protects user keystrokes from being recorded by applications or devices sniffing on the same local network. The encryption prevents the leakage of secret information such as usernames, passwords, credit-card data, and so on.
When Google TV starts, the Anymote service on Google TV starts sending
mDNS broadcasts on the local network containing
information such as "My IP address is xxx.xxx.x.x, I offer service
_anymote._tcp on port xxxx".
To discover Google TV devices on the network the remote application follows these steps:
- Probe the network with mDNS.
- Parse the responses it receives, looking for the string "_anymote._tcp".
- Extract the device name, IP address and port number from the mDNS response.
The figure below shows how the Anymote library displays the list of available Google TV devices extracted from mDNS response to the user. Users can then select the Google TV device that they want to control or add a Google TV device manually by entering the IP address of the device.
Figure 1: Device selection dialog
In addition to the Anymote service, the Pairing service also runs on all Google TV devices. The Pairing service is responsible for authenticating the remote devices. To communicate with Google TV using the Anymote protocol, the remote application should establish its identity with the Pairing service using the Google TV Pairing Protocol.
The remote applications establish a pairing session with Pairing service following the Pairing Protocol. The Pairing service runs on the next consecutive port of the Anymote service. For example, If Google TV Anymote service announces itself at port 9551 then the Pairing service listens on 9552. The client should connect to the next consecutive port of Anymote service to set up the pairing session.
The Pairing service issues a challenge for the remote application in the form of a QR/alphanumeric code that is displayed on the Google Tv device. The user has to scan/enter this code in the remote application.
Figure 2: Google TV Pairing service shows the secret pairing code
Figure 3: The remote application shows the dialog to enter the secret code
If the user successfully enters the pairing code and the pairing succeeds, the Pairing service sends a certificate to the remote application. The remote application should store the certificate in a secure, local key store, and use it for subsequent connection attempts with the Anymote service. A variety of key management systems are available to help manage the key store. The Google TV Remote Android application and the Anymote library uses Bouncy Castle, which is an open-source key management system.
The Distinguished Name (DN) in the certificate's subject field should uniquely identify the remote device. Duplicate entries are removed from the Google TV device. The trusted certificate is for a single remote application. Other apps on the same remote device must go through the pairing process and get their own certificates.
For more information refer to:
The Anymote Protocol uses protocol buffers to package up requests and responses. The remote application sends a RequestMessage to Anymote service on Google TV. Anymote service responds with a ResponseMessage.
The RequestMessage specifes a event, and provides data about the event. Events can be:
- key events (such as volume up and down)
- mouse events
- mousewheel events
- connection events (such as when the remote application connects to Anymote service)
The remote application can send an Intent to Anymote service to launch a Google TV application or view content that is available on Google TV. The Intent should be converted to a String by calling Intent.toUri(int) and sent using the Anymote protocol.
Here are some code snippets that demonstrate sending an Intent to Google TV:
Intent to launch a app
final Intent intent = new Intent(); intent.setAction ("com.example.googletv.myApp.VIEW_ACTION"); anymoteSender.sendUrl (intent.toUri(Intent.URI_INTENT_SCHEME));
Intent to view a webpage
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://<webpage_url>"); anymoteSender.sendUrl (intent.toUri(Intent.URI_INTENT_SCHEME));
Intent to view a Youtube video
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://<video_id>"); anymoteSender.sendUrl (intent.toUri(Intent.URI_INTENT_SCHEME));
For more information refer to: