Version: Smart Feature Phone 3.0

PowermanagerService service

Instanciating the service#

Load the following scripts:

<script src="http://127.0.0.1/api/v1/shared/core.js"></script>
<script src="http://127.0.0.1/api/v1/shared/session.js"></script>
<script src="http://127.0.0.1/api/v1/powermanager/service.js"></script>

You can then get an instance of the service with code similar to:

const session = new lib_session.Session();
const sessionstate = {};
let _powermanagerManager = null;
sessionstate.onsessionconnected = function () {
console.log(`PowermanagerService onsessionconnected`);
lib_powermanager.PowermanagerService.get(session).then((PowermanagerServiceService) => {
console.log(`Got PowermanagerService : #PowermanagerServiceService.service_id}`);
_powermanagerManager = PowermanagerServiceService;
}).catch((e) => {
console.log(`Error calling PowermanagerService service${JSON.stringify(e)}`);
_powermanagerManager = null;
});
};
sessionstate.onsessiondisconnected = function () {
console.log(`PowermanagerService onsessiondisconnected Daemon Crashed`);
};
// On desktop version, set ENV WS_RUNTIME_TOKEN=secrettoken
session.open('websocket', 'localhost', 'secrettoken', sessionstate, true);

Then the developer can use _powermanagerManager as PowermanagerService service instance.

This service implements the Powermanager interface.


FactoryResetReason enumeration#

{
NORMAL,
WIPE,
ROOT
}

ScreenState enumeration#

{
ON,
OFF
}

ScreenControlInfo dictionnary#

{
state: <a href="#enumeration_ScreenState">ScreenState?</a>,
brightness: integer?,
isExternal: boolean
}

Powermanager Interface#

Members#

cpuSleepAllowed

extScreenBrightness

extScreenEnabled

factoryReset

keyLightBrightness

keyLightEnabled

screenBrightness

screenEnabled

cpuSleepAllowed is of type boolean

To get value, use code similar to:

_powermanagerManager.cpuSleepAllowed().then(value => { ... });

To set value, use code similar to:

_powermanagerManager.cpuSleepAllowed = value;

extScreenBrightness is of type integer

To get value, use code similar to:

_powermanagerManager.extScreenBrightness().then(value => { ... });

To set value, use code similar to:

_powermanagerManager.extScreenBrightness = value;

extScreenEnabled is of type boolean

To get value, use code similar to:

_powermanagerManager.extScreenEnabled().then(value => { ... });

To set value, use code similar to:

_powermanagerManager.extScreenEnabled = value;

factoryReset is of type FactoryResetReason

To get value, use code similar to:

_powermanagerManager.factoryReset().then(value => { ... });

To set value, use code similar to:

_powermanagerManager.factoryReset = value;

keyLightBrightness is of type integer

To get value, use code similar to:

_powermanagerManager.keyLightBrightness().then(value => { ... });

To set value, use code similar to:

_powermanagerManager.keyLightBrightness = value;

keyLightEnabled is of type boolean

To get value, use code similar to:

_powermanagerManager.keyLightEnabled().then(value => { ... });

To set value, use code similar to:

_powermanagerManager.keyLightEnabled = value;

screenBrightness is of type integer

To get value, use code similar to:

_powermanagerManager.screenBrightness().then(value => { ... });

To set value, use code similar to:

_powermanagerManager.screenBrightness = value;

screenEnabled is of type boolean

To get value, use code similar to:

_powermanagerManager.screenEnabled().then(value => { ... });

To set value, use code similar to:

_powermanagerManager.screenEnabled = value;

Methods#

  controlScreen powerOff reboot

// info: ScreenControlInfo
controlScreen(info)

Resolves with void

Rejects with void


powerOff()

Resolves with void

Rejects with void


reboot()

Resolves with void

Rejects with void


Sample code#

New APIs sample code