目录

Screen Brightness

has.setScreenBrightness

has.setScreenBrightness (Object object)

Sets screen brightness. The setting is effective only for the current atomic service.

Since: 1.0.4

Parameters

The input parameter is an object containing the following fields.

Name

Type

Mandatory

Description

value

number

Yes

Screen brightness. The value range is [0, 1], where 0 means darkest and 1 means brightest. The value -1 indicates that the screen brightness changes with the system.

success

function

No

Callback to be invoked when the API call is successful.

fail

function

No

Callback to be invoked when the API call fails.

complete

function

No

Callback to be invoked when the API call is complete, regardless of success or failure.

Example
has.setScreenBrightness({
  value: 0.5,
  success() {},
  fail(error) {},
  complete() {}
});

has.setKeepScreenOn

has.setKeepScreenOn (Object object)

Sets whether to keep the screen steady on. The setting is effective only for the current atomic service.

Since: 1.0.4

Parameters

The input parameter is an object containing the following fields.

Name

Type

Mandatory

Description

keepScreenOn

boolean

Yes

Whether to keep the screen steady on.

success

function

No

Callback to be invoked when the API call is successful.

fail

function

No

Callback to be invoked when the API call fails.

complete

function

No

Callback to be invoked when the API call is complete, regardless of success or failure.

Example
has.setKeepScreenOn({
  keepScreenOn: true,
  success() {},
  fail(res) {},
  complete() {}
});

has.onUserCaptureScreen

has.onUserCaptureScreen (function callback)

Enables listening for proactive screenshot events. Such an event is triggered when a user takes a screenshot by pressing the system screenshot button. Only one listener can be registered.

Since: 1.0.4

Parameters

Name

Type

Mandatory

Description

callback

function

Yes

Callback for the proactive screenshot event.

Example
has.onUserCaptureScreen(function () {
  console.log('Screenshot event captured');
});

has.offUserCaptureScreen

has.offUserCaptureScreen (function callback)

Cancels listening for proactive screenshot events.

Since: 1.0.4

Parameters

Name

Type

Mandatory

Description

callback

function

No

Callback for the proactive screenshot event.

Example
const fun = () => {
  console.info('screenshotCallback');
};

has.onUserCaptureScreen(fun);
has.offUserCaptureScreen(fun);

has.getScreenBrightness

has. getScreenBrightness (Object object)

Obtains the current screen brightness of the atomic service.

Since: 1.0.4

Parameters

The input parameter is an object containing the following fields.

Name

Type

Mandatory

Description

success

function

No

Callback to be invoked when the API call is successful.

fail

function

No

Callback to be invoked when the API call fails.

complete

function

No

Callback to be invoked when the API call is complete, regardless of success or failure.

Return value of success

Attribute

Type

Description

value

number

Screen brightness. The value range is [0, 1], where 0 means darkest and 1 means brightest. The value -1 indicates that the screen brightness changes with the system.

Example
has.getScreenBrightness({
  success: function success(res) {
  console.log ('Screen brightness: ' + res);
  },
  fail(res) {},
  complete() {}
});