system

This module provides system-level device control functionalities for Total Control environments.
It enables interaction with Android devices via JavaScript, offering APIs for device status querying, system configuration, screen control, and command execution.

Key Features:

  • Retrieve device properties: name, battery, screen orientation, IP, clipboard, brightness, volume, etc.
  • Modify device settings: clipboard content, brightness, input method, volume levels, and Wi-Fi state.
  • Control screen behavior: lock, unlock, sleep, wakeup.
  • Execute shell and ADB commands on connected devices.
  • Support for both single device and multiple device operations (Device and DeviceArray).
  • Utility functions for getting cursor coordinates, SD card path, temp path, and display mode.

ADB Integration:

  • Automatically detects and executes ADB commands via configured path.
  • Supports SN-based device targeting and command chaining.

Basic Usage:

  1. Import the module via require("sigma/system").
  2. Get a device object using Device.getMain() or Device.searchObject().
  3. Use methods like get(), set(), exec(), adb() directly on the device instance.

Example APIs:

  • device.get("text:clipboard"): Read clipboard content
  • device.set("wifi:enable", true): Enable Wi-Fi
  • device.exec("ls /sdcard"): Execute a shell command
  • device.adb("shell pm list packages"): Run an ADB command
  • device.sleep(), device.unlock(), device.wakeup(): Manage device screen state

This module attaches methods to Device.prototype and DeviceArray.prototype,
and exposes ADB functions separately.

(inner) adb(adbCommand) → {string|null}

Executes an ADB command on the current device.

Example
// Example: List all installed package names on the device
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
    var ret = sigmaDevice.adb("shell pm list packages");
    if (ret != null) {
        print("Congratulations, this API executes successfully.\nReturn value: " + ret);
    } else {
        print("Sorry! " + lastError() + "\nReturn value: " + ret);
    }
} else {
    print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value:
package:com.huawei.camera
package:com.huawei.android.launcher
package:com.android.mediacenter
...
Parameters:
string adbCommand

The adb shell command to be executed (e.g., "shell pm list packages").

Returns:
string | null

Successfully returns the result of executing the adb command; if the execution fails, you can get the specific error information through the lastError() function.

(inner) displayMode() → {number|null}

Get the display mode of the device, that is, whether the device is in the Total Control or the window mode.

Example
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  // Execute this JS API
  var ret = sigmaDevice.displayMode();
  if (ret === 1 || ret === 2) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}
Returns:
number | null

Returns 1 or 2 on success:

  • 1: means WDM mode, window mode;
  • 2: means MDCC mode, multi-control center;
    Returns null on failure. Use lastError() to get the error message.

(inner) exec(command, timeoutopt) → {string|null}

The command is executed synchronously on the device shell console. A synchronous call is a command execution method that can be executed in a short time and does not require user interaction. Such as ls, cat, etc.

Example
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  // Execute a shell command
  var ret = sigmaDevice.exec("ls -l /sdcard/aa/", 3000);
  if (ret != null) {
    print("Congratulations, this API executes successfully.\nReturn value: \n" + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result Example:
-rwxrwx--- root     sdcard_r    79749 2019-04-16 13:15 image0.png
-rwxrwx--- root     sdcard_r    54699 2019-04-16 13:15 image10.jpg
-rwxrwx--- root     sdcard_r       34 2019-04-29 10:53 test2.txt
-rwxrwx--- root     sdcard_r       17 2019-04-29 10:53 test3.txt
Parameters:
string command

The command that needs to be executed. (e.g., "ls -l /sdcard/aa/").

number timeout <optional>

Timeout (milliseconds).

Returns:
string | null

Successfully returns the result of executing the command; if the execution fails, you can get the specific error information through the lastError() function.

(inner) get(type) → {*}

Gets system or device information by a specific type key.

This method supports querying a wide range of runtime values such as clipboard content,
network information, volume level, brightness, IME list, and device display or build properties.

    1. Get the contents of the device clipboard
      String, returns the contents of the clipboard
    1. Get the IP of the device
      String, returns the IP of the device
    1. Get the device wireless communication
      Boolean: returns true or false, false means off, true means on.
    1. Get device volume
      Int, returns the volume value of the specified type
    1. Get device brightness
      Int, return device
    1. Get device ime
      An array of strings, returns the ime name.
    1. Get the acceleration mode of the device
      Int, returns acceleration mode of the device, the details are as follows:
      1 – indicates that the device acceleration is HA1;
      2 – indicates that the device acceleration is HA2;
      3 – indicates that the device acceleration is Comp;
    1. Get the display quality of the device
      Constant value, returns the display quality of the device, the details are as follows:
      1 - High
      2 - Medium
      3 - Low
    1. Get computer acceleration mode
      Constant value, returns computer acceleration mode, the details are as follows:
      1 – GDI
      2 – DirectX
      3 - OpenGL
    1. Get whether to use hardware decoding
      Int, returns whether to use hardware decoding, the details are as follows:
      1 – Yes
      0 – No
    1. Get the resolution mode displayed by the device
      Int, returns resolution mode, the details are as follows:
      1 - 480p
      2 - 640p
      3 - 720p
      4 - 1080p
    1. Get the display direction of the device
      Int, returns the display direction of the device, the details are as follows:
      1 – Portrait; (vertical screen)
      2 – Landscape; (horizontal screen)
    1. Get the width and height of the device screen
      String, returns the width and height of the device screen, for example: {h: 1920, w: 1080}
    1. Get H.264 configuration file name and level
      Only the acceleration mode 1 and acceleration mode 2 of the device are H.264. When the device's acceleration mode is "High Compatibility", it is not H.264, the value cannot be obtained, null is returned, and error message can be obtained through lastError()
      Int, returns the H.264 configuration file name and level, the details are as follows:
      1 - base;
      2 - main;
      8 - high;
    1. Get build type
      String, returns build type, the details are as follows:
      cn - China
      us - international
Example
// Example 1: Get clipboard content
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
var ret = sigmaDevice.get("text:clipboard");
if (ret != null) {
  print("The contents of the clipboard are \"" + ret + "\"");
} else {
  print("Failed to get. Error: " + lastError());
}


// Example 2: Get device IP
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
var ip = sigmaDevice.get("Network:IP");
print("The device IP is \"" + ip + "\"");


// Example 3: Check if Wi-Fi is enabled
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
var wifiStatus = sigmaDevice.get("wifi:enable");
print(wifiStatus === true ? "The wifi is open" : "The wifi is close");


// Example 4: Get ring volume
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
var volume = sigmaDevice.get("sound:volume:ring");
print("The ring volume is " + volume);


// Example 5: Get brightness
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
var brightness = sigmaDevice.get("display:brightness");
print("The brightness is " + brightness);


// Example 6: Get IME list
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
var imeList = sigmaDevice.get("ime:allList");
print("Input methods:\n" + imeList);


// Example 7: Get device display info
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
print("Display mode: " + sigmaDevice.get(tcConst.DisplayMode));
print("Display quality: " + sigmaDevice.get(tcConst.DisplayQuality));
var resolution = sigmaDevice.get(tcConst.DisplayResolution);
print("Screen size: " + resolution.w + "x" + resolution.h);


// Example 8: Get build country code
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
var countryCode = sigmaDevice.get(tcConst.BuildCountryCode);
print("Build country code: " + countryCode);
Parameters:
string type

The key specifying what value to get.
Common formats include:
- "text:clipboard" for clipboard text
- "Network:IP" for IP address
- "wifi:enable" for Wi-Fi status (true/false)
- "bluetooth:enable" for device Bluetooth
- "mobile_data:enable" for Device data traffic
- "sound:volume:ring" for ring volume
- "sound:volume:notify" for notification volume
- "sound:volume:media" for media volume
- "sound:volume:alarm" for alarm volume
- "sound:volume:all" for all
- "display:brightness" for screen brightness
- "ime:allList" for all ime on the device
- "ime:enabledList" for all ime set on the device

                   - Or predefined constants like `tcConst.DisplayMode`, `tcConst.BuildCountryCode`, etc.
Returns:
*

The queried value. Type depends on the query:
- string for text values (clipboard, IP, IME list, build info)
- number for numeric values (volume, brightness, display quality)
- boolean for flags (Wi-Fi enabled)
- object for complex data (e.g., resolution { w, h }, H.264 profile { name, level })
- null if the query fails. Use lastError() for details.

(inner) getAcceleration() → {number}

Get the rendering mode used by the device.

Example
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  // Execute this JS API
  var ret = sigmaDevice.getAcceleration();
  if (ret !== -1) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

//Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: 1
Returns:
number

Successfully returns the rendering mode(0,1,2) of the device:

  • 0: means "GDI";
  • 1: means "D3D";
  • 2: means "OpenGL".
    If the execution fails, you can get the specific error information through the lastError() function.

(inner) getCursorPos(type) → {Object|null}

Get the position of the mouse on the computer screen, you can get the absolute coordinates of the mouse relative to the computer screen, or the absolute coordinates of the mouse relative to the phone window, or the relative coordinates of the mouse relative to the phone window.

Example
// Get relative cursor position on the device (0.0–1.0 range)
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.getCursorPos(tcConst.DeviceRelCoor);
  if (ret != null) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret.x + "/" + ret.y);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return (example with relative coordinates):
Congratulations, this API executes successfully.
Return value: 0.7458000183105469/0.7070000171661377
Parameters:
number type

The coordinate type constant. Acceptable values:

  • tcConst.ScreenAbsCoor: Constant value, get the absolute coordinates of the mouse relative to the computer screen. In pixels, such as (100, 200)
  • tcConst.DeviceAbsCoor: Gets the absolute coordinates of the mouse relative to the phone window, in pixels, such as (100, 200). Returns NULL if the mouse is not inside the phone window.
  • tcConst.DeviceRelCoor: Get the relative coordinates of the mouse relative to the phone window, such as (0.5, 0.2). Returns NULL if the mouse is not inside the phone window.
Returns:
Object | null

If it succeeds, it returns the coordinate object. You can use [coordinate object.x] and [coordinate object.y] to get the coordinate value of the mouse. If it fails, it returns NULL, you can get the specific error information through the lastError() function.

(inner) getName() → {string|null}

Get the name of the device. If the alias of the device is not set, the physical name of the device is returned; if the alias of the device is set, the device alias is returned.
Note: Only the Professional Edition can set an alias on the interface.
Lite can only set an alias via the interface "setName".

Example
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.getName();
  if (ret != null) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: HUAWEI-HUAWEI P7-L07
Returns:
string | null

The device name if successful, or null on failure.
Use lastError() to retrieve error details.

(inner) getNo() → {number}

Get the serial number of the device, for example: 5.

This number indicates the device's position in the list of connected devices.
The first device is usually indexed as 0.

Example
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.getNo();
  if (ret !== -1) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: 0
Returns:
number

In the multi-control center (MDCC), return the device serial number, such as 1, 2, 3; Not in the multi-control center, always returns 0.

(inner) getOrientation() → {number}

Get the rotation direction of the device's screen.

  • 0: Screen rotation 0°, portrait (vertical screen)
  • 1: Screen rotation 90°
  • 2: Screen rotation 180°, landscape (horizontal screen)
  • 3: Screen rotation 270°
Example
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.getOrientation();
  if (ret !== -1) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: 0
Returns:
number

The direction of rotation of the device's screen.

(inner) getRemainingBattery() → {number}

Get the remaining battery of the device.

Example
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.getRemainingBattery();
  if (ret !== -1) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: 90
Returns:
number

Device power (percentage).

(inner) getSDPath() → {string|null}

Get the SD card directory path of the device.

Example
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.getSDPath();
  if (ret != null) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: /sdcard
Returns:
string | null

The path name of the sdcard.

(inner) getSetting(type) → {Object|string|null}

Retrieves Total Control configuration properties or device-level settings.

This API is used to get various system or device-level parameters based on the specified type.
It supports both global system calls (e.g., installation paths) and device-specific settings (when called via device.getSetting(type)).

Example
// Example 1: Get the installation, working address and adb path of Total Control
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
var ret = sigmaDevice.getSetting(tcConst.Pathname);
if (ret != null) {
  print("Get the properties of Total Control successfully, the value is:\n" + JSON.stringify(ret));
} else {
  print("Failed to get. The error is : " + lastError());
}


// Example 2: Get the build type of Total Control (called from device)
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
var ret = sigmaDevice.getSetting(tcConst.BuildCountryCode);
if (ret != null) {
  print("Get build type successfully, the value is: " + ret);
} else {
  print("Failed to get. The error is : " + lastError());
}


// Example 3: Get the AAI status of Total Control
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
var ret = sigmaDevice.getSetting(tcConst.aaiAvailable);
if (ret == true) {
  print("AAI is turned on.");
} else {
  print("AAI is turned off.");
}

// Operation Result:
// If it executes successfully, it may return:
// Example 1:
{
  "installPath": "C:\\Program Files\\Sigma-RT\\Total Control",
  "workingPath": "C:\\Users\\xiaofu\\Documents\\Scripts",
  "adbPath": "C:\\Program Files\\Sigma-RT\\Total Control\\adb\\adb2.exe"
}

// Example 2:
Get build type successfully, the value is: cn

// Example 3:
AAI is turned on.
Parameters:
string type

The type of setting to retrieve. For example:

  • tcConst.Pathname for get Total Control's installation, working address and adb path
  • tcConst.BuildCountryCode for get the build type of Total Control
  • tcConst.aaiAvailable for get the AAI status of Total Control. If the AAI is turned on,it returns ture. If the AAI is turned off,it returns false.
Returns:
Object | string | null

Returns the setting value.

  • If tcConst.Pathname is used, returns an object with installPath, workingPath, and adbPath.
  • If requesting a device-level property (e.g., BuildCountryCode), returns a string, and the corresponding meaning of the value is as follows:
    cn - China
    en - International

Returns null on failure; use lastError() for more details.

(inner) getTmpPath() → {string|null}

Get the temporary file directory on the device memory card.

Example
// Example: Get the temporary path of the current device
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.getTmpPath();
  if (ret != null) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: /data/local/tmp
Returns:
string | null

Returns the absolute path to the temporary directory on the device (e.g., /data/local/tmp).
Returns null if the operation fails. Use lastError() to retrieve error details.

(inner) getWidth() → {number|null}

Retrieves the screen width (in pixels) of the connected Android device.

This method returns the current width of the device display, which is useful for layout calculations,
coordinate scaling, or screen size validations.

Example
// Example: Get the screen width of the connected device
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.getWidth();
  if (ret != -1) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: 720
Returns:
number | null

Returns the screen width in pixels (e.g., 720).
Returns -1 or null if the operation fails. Use lastError() to retrieve error details.

(inner) lock(timeout) → {number|null}

lock(timeout)

Locks the device screen for the specified amount of time.
This method is often used in automation to prevent user interaction during a script execution phase.

Example
// Example: Lock the device for 60 seconds
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.lock(60000);
  if (ret != -1) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: 0
Parameters:
number timeout

Duration to lock the device in milliseconds. For example, 60000 for 60 seconds.

Returns:
number | null

Returns 0 on success.
Returns -1 or null on failure. Use lastError() to get detailed error information.

(inner) set(type, value) → {boolean|null}

Set device properties, supports setting multiple devices at the same time. When setting multiple devices, you can use devices.set(type, value), when setting only one device, you can use device.set(type, value).

Example
// Example 1: Set clipboard to "Hi"
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
var ret = sigmaDevice.set("text:clipboard", "Hi");
if (ret === true) {
  print("Set successfully");
} else if (ret === false) {
  print("Execute API successfully but failed to set.");
} else {
  print("Failed to execute API, the error is: " + lastError());
}


// Example 2: Enable Wi-Fi
sigmaDevice.set("wifi:enable", true);


// Example 3: Set volume to 50%
sigmaDevice.set("sound:volume:all", 50);


// Example 4: Set screen brightness
sigmaDevice.set("display:brightness", 100);


// Example 5: Set IME
sigmaDevice.set("ime:set", "com.sigma_rt.totalcontrol/.ap.service.SigmaIME");


// Example 6: Multi-device set
var sigmaDevices = Device.searchObject(sigmaConst.DevAll);
sigmaDevices.set("ime:set", "sigma");


// Example 7: Disable IME
sigmaDevice.set("ime:disable", "com.sigma_rt.totalcontrol/.ap.service.SigmaIME");

// Operation Result:
// If it executes successfully, it will return:
Set successfully
Parameters:
string type

The target setting to modify. Supported formats include:

  • "text:clipboard" Set clipboard text
  • "Network:IP" for IP address
  • "wifi:enable" Enable/disable Wi-Fi
  • "bluetooth:enable" Set device Bluetooth
  • "mobile_data:enable" Set Device data traffic
  • "sound:volume:ring" Set ring volume
  • "sound:volume:notify" Set notification volume
  • "sound:volume:media" Set media volume
  • "sound:volume:alarm" Set alarm volume
  • "sound:volume:all" Set all volume types
  • "display:brightness" Set screen brightness
  • "ime:allList" Set all ime on the device
  • "ime:enabledList" Set all ime set on the device
  • "ime:set": Set the active input method
  • "ime:disable": Disable a specific input method
* value

The value to set. Its type depends on the type parameter, e.g.:

  • String for clipboard text and IME ID
  • Boolean for Wi-Fi state
  • Number for volume or brightness
Returns:
boolean | null

Returns:

  • true on successful setting
  • false if API executed but setting failed
  • null if the API execution itself failed (check lastError())

(inner) setName(name) → {number}

Sets the display name of the current device instance in Total Control.

Example
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.setName("mobile2");
  if (ret !== -1) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: 0
Parameters:
string name

The new name to assign to the device (e.g. "mobile2").

Returns:
number

Returns:

  • 0 if the name was set successfully
  • -1 if the operation failed (check lastError() for details)

(inner) sleep() → {number}

Puts the device into sleep mode (turns off the screen).

Example
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.sleep();
  if (ret === 0) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: 0
Returns:
number

Returns:

  • 0 if the operation succeeds
  • -1 if the operation fails (check lastError() for details)

(inner) unlock() → {number}

Unlock the "Total Control" control interface.

Example
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.unlock();
  if (ret === 0) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: 0
Returns:
number

Returns:

  • 0 if the operation succeeds
  • -1 if the operation fails (check lastError() for error details)

(inner) wakeup() → {number}

Wakes up the device screen (simulates pressing the power button to turn on the screen).

Example
var { Device } = require("sigma/device");
var system = require("sigma/system");
// Get the current master device object
var sigmaDevice = Device.getMain();
if (sigmaDevice != null) {
  var ret = sigmaDevice.wakeup();
  if (ret === 0) {
    print("Congratulations, this API executes successfully.\nReturn value: " + ret);
  } else {
    print("Sorry! " + lastError() + "\nReturn value: " + ret);
  }
} else {
  print("Failed to get the master device object");
}

// Operation Result:
// If it executes successfully, it will return:
Congratulations, this API executes successfully.
Return value: 0
Returns:
number

Returns:

  • 0 if the operation succeeds
  • -1 if the operation fails (check lastError() for error details)