Page Example

System Info Sample Overview

The SystemInfo sample application demonstrates how system-related information can be retrieved using Web Device API.

The following figure illustrates the main screen and example details of the System Info.

Figure: System Info screens

System Info screens

The application opens with the main screen that displays a list of system information items. To see the details of a specific item, click on the item.

Source Files

You can create and view the sample application project including the source files in the IDE.

File name Description
config.xml This file contains the application information for the platform to install and launch the application, including the view mode and the icon to be used in the device menu.
css/style.css This file contains the CSS styling for the application UI.
images/ This directory contains the application icon.
index.html This is a starting file from which the application starts loading. It contains the layout of the application screens.
js/core/ This directory contains the application framework.
js/helpers/capabilities.js This file contains helpers for handling device capability information.
js/helpers/parser.js This file contains helpers for handling system information data, such as battery, CPU, device orientation, display, storage, and packages information.
js/models/systemInfo.js This file contains methods that handle the System Information and Package API data.
js/views/main.js This file contains the code related to application UI.
js/app.js This file contains the application initializer.
lib/tau/ This directory contains the external libraries (TAU library).

Implementation

To see detailed information about system property, click on the item. For example:

/* views/main.js */
batteryButton.addEventListener('click', function onBatteryButton() 
{
   systemInfo.getSystemProperty('BATTERY', onBatteryInfo);
   plId = systemInfo.addPropertyListener('BATTERY', onBatteryInfo);
});

The information received is parsed and displayed on the new property detail page.

/* view/main.js */
function onBatteryInfo(battery) 
{
   var data = parser.parseBatteryInfo(battery);

   displayPage('details', 'Battery', data);
}

The following function requests for information on installed packages.

/* models/systemInfo.js */
function getPackagesInfo(onSuccess) 
{
   try 
   {
      tizen.package.getPackagesInfo(onSuccess);
   } 
   catch (error) 
   {
      onError(error);
   }
}

The following function requests for the package details.

/* models/systemInfo.js */
function getPackageDetails(packageId, onSuccess) 
{
   try 
   {
      onSuccess(tizen.package.getPackageInfo(packageId));
   } 
   catch (error) 
   {
      onError(error);
   }
}

The following function requests for the system property value.

/* models/systemInfo.js */
function getSystemProperty(property, onSuccess) 
{
   try 
   {
      tizen.systeminfo.getPropertyValue(property, onSuccess, onError);
   } 
   catch (error) 
   {
      onError(error);
   }
}

The following function adds the property value change listener.

/* models/systemInfo.js */
function addPropertyListener(property, onChange) 
{
   try 
   {
      return tizen.systeminfo
      .addPropertyValueChangeListener(property, onChange);
   } 
   catch (error) 
   {
      onError(error);
   }
}

The following function removes the current property value change listener.

/* models/systemInfo.js */
function removePropertyListener(listenerId) 
{
   try 
   {
      tizen.systeminfo.removePropertyValueChangeListener(listenerId);
   } 
   catch (error) 
   {
      onError(error);
   }
}

The following function requests for the device capability value.

The function argument is a special key, such as http://tizen.org/feature/camera.back or http://tizen.org/feature/network.bluetooth. For a list of the available keys and their meaning, see the device capability keys.

/* models/systemInfo.js */
function getCapability(capability) 
{
   var isSupported = false;

   try 
   {
      isSupported = tizen.systeminfo.getCapability(capability);
   } 
   catch (error) 
   {
      onError(error);
   }

   return isSupported;
}