FAQ

Service Manager

Published: September 16, 2019
Edited: November 29, 2019

Overview

The Service Manager provides a uniform method for accessing services on the target device. The goal of this component is to provide methods for discovering the services available on a device and enable access to them in a uniform and cross-platform way. The main role of the Service Manager is to allow for platform-specific code to register services. The Service Manager  acts as a service factory allowing for the registered service objects to be returned to the caller.

Every service registered with the Service Manager possesses the following capabilities:

  • Contains properties which may be queried or set.
  • Publishes methods that can be called with parameters.
  • Generates events and allows listeners to be registered for them.

Component Interactions

The Service Manager is implemented as a single class holding a list of registered services. For each service,  the Service Manager keeps a name and a pointer to a factory function used to create or return an instance of the given service.

Exported APIs

The Service Manager is accessible using a C++ or a JavaScript API.

The C++ API provides a singleton Service Manager object that can be used to:

  • register or unregister services,
  • query service registration,
  • create service objects of a registered service.

The JavaScript API is accessible using the Service Manager global name in the QWebFrame context. The object provides a getServiceForJavaScript() method that allows retrieval of the service object for a given service.

Required APIs

The Service Manager core depends on the Qt library (optionally also on the Qt Webkit library for JavaScript support).

Individual services may introduce additional dependencies.

No HAL API is defined for Service Manager.

Service Manager Development

Naming Conventions

 Service Manager follows a set of naming conventions for all new services in attempts to unify and simplify code development and API access. 

Service Names

  • prefixed with a namespace

use com.comcast or other prefix for services that are specific to an organization

use org.rdk prefix for services that are expected to be generic and released into the RDK

  • useCamelCaseForServiceNames
  • postfix with a version number
  • do not include “API” or “service” in the service name
  • Example  org.rdk.wifiManager_1

Method Names

  • useCamelCaseForMethodNames
  • should be descriptive

Event Names

  • start with “on”
  • useCamelCase
  • should be descriptive

Parameters

  • useCamelCaseForParameterNames
  • names should be descriptive
  • return values can be a primitive data type or object/hash. Type annotations can be specified for clarity.

Constant Names

  • USE_ALL_CAPS_WITH_UNDERSCORES_FOR_CONSTANT_NAMES
  • should be descriptive

Create a new Service

  1.   Add a new class which should be inherited from “service”
  2.   Implement the virtual function defined in “service”  .

  Every new service should have the following functions:

  • CallMethod – Actual functionality implemented by this service should go in this.
  • AddWebFrame – Add a new JavaScript object, required if you want to expose this service to html JavaScript.
  • getJavaScriptObject – Returns the previously added JavaScript object.

To Implement the service, take any existing service and simply change the name and implement the Call Method function

Register a new Service

Please see the below example for registering new service to the rdk browser

ServiceStruct serviceStruct;
serviceStruct.createFunction = &createDisplaySettingsService;
serviceStruct.serviceName =org.openrdk.displaySettings;
ServiceManager::getInstance() ->registerService(org.openrdk.displaySettings, serviceStruct);

Available Services

Here are all of the ServiceManager APIs currently supported:

NameDescription
SystemThe System API provides an interface for interrogating or controlling the system as a whole.
HDMI InputThe HDMI Input replaces AVInput for HDMI input control
Front PanelThe FrontPanel API provides an interface for managing front panel leds.
ScreenCaptureInterfacing for taking and uploading screenshots.
State ObserverGet the value of various device properties and set up event listeners to be notified when the state of the device changes.
Browser SettingsInterface for removing web browser cookies and cache.
WebSocket APIThe WebSocket API provides an interface to initiating WebSocket connections.
Memory Info The MemoryInfo API is used as a interface to get the memory details like VmSize, Shared pages,Data + stack etc.
Home NetworkingThe HomeNetworking Api is used as a interface for DLNA feature.
Display SettingThe DisplaySetting service is used to get the diaply information like currentVideoResolution,SupportedVideoDisplays,ZoomSetting,SoundMode,ConnectedVideoDisplays etc
Storage ManagerProvides information for storage devices on the system and an API for accessing and modifying TSB properties.
Frame RateProvides information about frame rates.
ApplicationThe Application API defines methods to discover and manage applications and server connections.
HDMI CECThe HDMI CEC defines APIs to perform CEC related operations.
PingThe Ping API provides the ability to ping specific or named endpoints.
BluetoothBluetooth API
Data CaptureAPI for capturing Audio or other data clips. Caller provides URL where captured clip shell be delivered.
HDCP ProfileAPI to HDCP Profile control, and HDCP Status notification
Logging PreferencesLogging Preferences is used to control key press logging
Wifi ManagerWifi Manager service
PHP Code Snippets Powered By : XYZScripts.com