Deviced API

To use Samsung Product API,

<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>

Should be loaded in index.html

This module defines Deviced API provided by the Tizen Samsung Product API.

Since : 10.0

Product : TV, B2B

Summary of Interfaces and Methods

Interface

Method

DevicedManagerObject

DevicedManager

DOMString getVersion();
long getBatteryCapacity();
BatteryPowerSource getBatteryPowerSource();

1. Type Definitions

1.1 BatteryPowerSource

Indicates the source of battery power

enum BatteryPowerSource {
  "NO_CHARGER",
  "AC_CHARGER",
  "USB_CHARGER",
  "WIRELESS_CHARGER"
};

The following values are supported

  • NO_CHARGER : No Charger Connected
  • AC_CHARGER : AC Charger Connected
  • USB_CHARGER : USB Charger Connected
  • WIRELESS_CHARGER : Wireless Charger Connected

2. Interfaces

2.1 DevicedManagerObject

Defines a WebApi object instance of the Tizen Samsung Product API.
The webapis.deviced object enables access to Deviced API functionality.

[NoInterfaceObject] interface DevicedManagerObject {
  readonly attribute DevicedManager deviced;
};
WebApi implements DevicedManagerObject;

Attributes

2.2 DevicedManager

Provides methods for Deviced functionalities.

[NoInterfaceObject] interface DevicedManager {
  DOMString getVersion();
  long getBatteryCapacity();
  BatteryPowerSource getBatteryPowerSource();
};

Methods

getVersion

Retrieves the plugin version number.

DOMString getVersion();

Return Value :

  • DOMString : Plugin version

Code Example :

try {
  var value = webapis.deviced.getVersion();
  console.log(" version value = " + value);
} catch (error) {
  console.log(" error code = " + error.code);
}

getBatteryCapacity

Get the current capacity of the battery

long getBatteryCapacity();

Return Value :

  • long : The battery capacity value 0-100

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if its not supporting battery.
    • with error type UnknownError, for any other error's like I/O.

Code Example :

try {
  var capacity = webapis.deviced.getBatteryCapacity();
  console.log("capacity = " + capacity);
} catch (error) {
  console.log("error code = " + error.code);
}

getBatteryPowerSource

Get the current Power source of the battery

BatteryPowerSource getBatteryPowerSource();

Return Value :

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if its not supporting battery.
    • with error type UnknownError, for any other error's like I/O.

Code Example :

try {
  var source = webapis.deviced.getBatteryPowerSource();
  console.log("source = " + source);
} catch (error) {
  console.log("error code = " + error.code);
}

3. Full WebIDL

module Deviced {
  enum BatteryPowerSource {
    "NO_CHARGER",
    "AC_CHARGER",
    "USB_CHARGER",
    "WIRELESS_CHARGER"
  };

  [NoInterfaceObject] interface DevicedManagerObject {
    readonly attribute DevicedManager deviced;
  };

  WebApi implements DevicedManagerObject;

  [NoInterfaceObject] interface DevicedManager {
    DOMString getVersion();
    long getBatteryCapacity();
    BatteryPowerSource getBatteryPowerSource();
  };

};