未验证 提交 89f809a6 编写于 作者: O openharmony_ci 提交者: Gitee

!23060 翻译完成 22013+21479+21433:js-apis-settings.md+js-apis-arkui-performancemonitor.md

Merge pull request !23060 from ester.zhou/TR-22013
...@@ -206,6 +206,7 @@ ...@@ -206,6 +206,7 @@
- [@ohos.arkui.dragController (DragController)](js-apis-arkui-dragController.md) - [@ohos.arkui.dragController (DragController)](js-apis-arkui-dragController.md)
- [@ohos.arkui.drawableDescriptor (DrawableDescriptor)](js-apis-arkui-drawableDescriptor.md) - [@ohos.arkui.drawableDescriptor (DrawableDescriptor)](js-apis-arkui-drawableDescriptor.md)
- [@ohos.arkui.inspector (Layout Callback)](js-apis-arkui-inspector.md) - [@ohos.arkui.inspector (Layout Callback)](js-apis-arkui-inspector.md)
- [@ohos.arkui.performanceMonitor (Performance Monitor)](js-apis-arkui-performancemonitor.md)
- [@ohos.arkui.UIContext (UIContext)](js-apis-arkui-UIContext.md) - [@ohos.arkui.UIContext (UIContext)](js-apis-arkui-UIContext.md)
- [@ohos.curves (Interpolation Calculation)](js-apis-curve.md) - [@ohos.curves (Interpolation Calculation)](js-apis-curve.md)
- [@ohos.font (Custom Font Registration)](js-apis-font.md) - [@ohos.font (Custom Font Registration)](js-apis-font.md)
......
# @ohos.arkui.performanceMonitor (Performance Monitor)
The **performanceMonitor** module provides APIs for performance monitoring indicators: response delay, completion delay, and frame loss rate.
> **NOTE**
>
> The APIs of this module are supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import
```ts
import performanceMonitor from '@ohos.arkui.performanceMonitor';
```
## ActionType
Enumerates types of actions that trigger user scenes.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name| Value| Description|
| -- | -- | -- |
| LAST_DOWN | 0 | Pressing against the screen. |
| LAST_UP | 1 | Lifting a finger off the screen.|
| FIRST_MOVE | 2 | First swiping on the screen.|
## performanceMonitor.begin
begin(scene: string, startInputType: ActionType, note?: string): void
Starts a user scene.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name| Type| Mandatory| Description|
| -- | -- | -- | -- |
| scene | string | Yes| User scene ID.|
| startInputType | [ActionType](#actiontype)| Yes| Type of action that triggers the user scene.|
| note | string| No| Important information about the user scene.|
**Example**
```ts
performanceMonitor.begin("LAUNCHER_APP_LAUNCH_FROM_ICON", performanceMonitor.ActionType.LAST_UP, "APP_START_BEGIN");
```
## performanceMonitor.end
end(scene: string): void
Ends a user scene.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name| Type| Mandatory| Description|
| -- | -- | -- | -- |
| scene | string | Yes| User scene ID, which corresponds to that in **begin**.|
**Example**
```ts
performanceMonitor.end("LAUNCHER_APP_LAUNCH_FROM_ICON");
```
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
The **settings** module provides APIs for setting data items. The **settings** module provides APIs for setting data items.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -24,8 +24,8 @@ Provides data items for setting the time and date formats. ...@@ -24,8 +24,8 @@ Provides data items for setting the time and date formats.
| ------------------- | ------ | ---- | ---- | ------------------------------------------------------------ | | ------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
| DATE_FORMAT | string | Yes | Yes | Date format.<br>The value can be **mm/dd/yyyy**, **dd/mm/yyyy**, or **yyyy/mm/dd**, where **mm** indicates the month, **dd** indicates the day, and **yyyy** indicates the year.| | DATE_FORMAT | string | Yes | Yes | Date format.<br>The value can be **mm/dd/yyyy**, **dd/mm/yyyy**, or **yyyy/mm/dd**, where **mm** indicates the month, **dd** indicates the day, and **yyyy** indicates the year.|
| TIME_FORMAT | string | Yes | Yes | Time format.<br>**12**: 12-hour format.<br>**24**: 24-hour format.| | TIME_FORMAT | string | Yes | Yes | Time format.<br>**12**: 12-hour format.<br>**24**: 24-hour format.|
| AUTO_GAIN_TIME | string | Yes | Yes | Whether the date, time, and time zone are automatically obtained from the Network Identity and Time Zone (NITZ).<br>The value **true** means that the date, time, and time zone are automatically obtained from NITZ; and **false** means the opposite. | | AUTO_GAIN_TIME | string | Yes | Yes | Whether the date, time, and time zone are automatically obtained from the Network Identity and Time Zone (NITZ).<br>The value **true** means that the date, time, and time zone are automatically obtained from NITZ;<br>and **false** means the opposite.|
| AUTO_GAIN_TIME_ZONE | string | Yes | Yes | Whether the time zone is automatically obtained from NITZ.<br>The value **true** means that the time zone is automatically obtained from NITZ; and **false** means the opposite. | | AUTO_GAIN_TIME_ZONE | string | Yes | Yes | Whether the time zone is automatically obtained from NITZ.<br>The value **true** means that the time zone is automatically obtained from NITZ;<br>and **false** means the opposite.|
## display ## display
...@@ -39,7 +39,7 @@ Provides data items for setting the display effects. ...@@ -39,7 +39,7 @@ Provides data items for setting the display effects.
| ----------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ | | ----------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
| FONT_SCALE | string | Yes | Yes | Scale factor of the font. The value is a floating point number. | | FONT_SCALE | string | Yes | Yes | Scale factor of the font. The value is a floating point number. |
| SCREEN_BRIGHTNESS_STATUS | string | Yes | Yes | Screen brightness. The value ranges from 0 to 255. | | SCREEN_BRIGHTNESS_STATUS | string | Yes | Yes | Screen brightness. The value ranges from 0 to 255. |
| AUTO_SCREEN_BRIGHTNESS | string | Yes | Yes | Whether automatic screen brightness adjustment is enabled.<br>**AUTO_SCREEN_BRIGHTNESS_MODE**: Automatic screen brightness adjustment is enabled.<br>**MANUAL_SCREEN_BRIGHTNESS_MODE**: Automatic screen brightness adjustment is disabled. | | AUTO_SCREEN_BRIGHTNESS | string | Yes | Yes | Whether automatic screen brightness adjustment is enabled.<br>**AUTO_SCREEN_BRIGHTNESS_MODE**: Automatic screen brightness adjustment is enabled.<br><br>**MANUAL_SCREEN_BRIGHTNESS_MODE**: Automatic screen brightness adjustment is disabled.|
| AUTO_SCREEN_BRIGHTNESS_MODE | number | Yes | Yes | Value of **AUTO_SCREEN_BRIGHTNESS** when automatic screen brightness adjustment is enabled. | | AUTO_SCREEN_BRIGHTNESS_MODE | number | Yes | Yes | Value of **AUTO_SCREEN_BRIGHTNESS** when automatic screen brightness adjustment is enabled. |
| MANUAL_SCREEN_BRIGHTNESS_MODE | number | Yes | Yes | Value of **AUTO_SCREEN_BRIGHTNESS** when automatic screen brightness adjustment is disabled. | | MANUAL_SCREEN_BRIGHTNESS_MODE | number | Yes | Yes | Value of **AUTO_SCREEN_BRIGHTNESS** when automatic screen brightness adjustment is disabled. |
| SCREEN_OFF_TIMEOUT | string | Yes | Yes | Waiting time for the device to enter the sleep state when not in use (unit: ms). | | SCREEN_OFF_TIMEOUT | string | Yes | Yes | Waiting time for the device to enter the sleep state when not in use (unit: ms). |
...@@ -47,7 +47,7 @@ Provides data items for setting the display effects. ...@@ -47,7 +47,7 @@ Provides data items for setting the display effects.
| ANIMATOR_DURATION_SCALE | string | Yes | Yes | Scale factor for the animation duration. This affects the start delay and duration of all such animations.<br>If the value is **0**, the animation ends immediately. The default value is **1**.| | ANIMATOR_DURATION_SCALE | string | Yes | Yes | Scale factor for the animation duration. This affects the start delay and duration of all such animations.<br>If the value is **0**, the animation ends immediately. The default value is **1**.|
| TRANSITION_ANIMATION_SCALE | string | Yes | Yes | Scale factor for transition animations.<br>The value **0** indicates that the transition animations are disabled. | | TRANSITION_ANIMATION_SCALE | string | Yes | Yes | Scale factor for transition animations.<br>The value **0** indicates that the transition animations are disabled. |
| WINDOW_ANIMATION_SCALE | string | Yes | Yes | Scale factor for normal window animations.<br>The value **0** indicates that window animations are disabled. | | WINDOW_ANIMATION_SCALE | string | Yes | Yes | Scale factor for normal window animations.<br>The value **0** indicates that window animations are disabled. |
| DISPLAY_INVERSION_STATUS | string | Yes | Yes | Whether display color inversion is enabled.<br>**1**: Display color inversion is enabled.<br>**0**: Display color inversion is disabled.| | DISPLAY_INVERSION_STATUS | string | Yes | Yes | Whether display color inversion is enabled.<br>**1**: Display color inversion is enabled.<br><br>**0**: Display color inversion is disabled.|
## general ## general
...@@ -186,57 +186,57 @@ Provides data items for setting wireless network information. ...@@ -186,57 +186,57 @@ Provides data items for setting wireless network information.
| WIFI_WATCHDOG_STATUS | string | Yes | Yes | Whether Wi-Fi watchdog is available.<br>**true**: Wi-Fi watchdog is available.<br>**false**: Wi-Fi watchdog is unavailable.| | WIFI_WATCHDOG_STATUS | string | Yes | Yes | Whether Wi-Fi watchdog is available.<br>**true**: Wi-Fi watchdog is available.<br>**false**: Wi-Fi watchdog is unavailable.|
## settings.setValue ## settings.setValue<sup>10+</sup>
setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object, callback: AsyncCallback\<boolean>): void setValue(context: Context, name: string, value: string, callback: AsyncCallback\<boolean>): void
Sets the value for a data item. This API uses an asynchronous callback to return the result. Sets the value for a data item. This API uses an asynchronous callback to return the result.
**System API**: This is a system API. **Model restriction**: This API can be used only in the stage model.
**System capability**: SystemCapability.Applications.settings.Core **System capability**: SystemCapability.Applications.settings.Core
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ----------------------- | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | | context | Context | Yes | Application context.<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items| | name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
| value | object | Yes | Value of the data item. The value range varies by service. | | value | string | Yes | Value of the data item. The value range varies by service. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. Returns **true** if the operation is successful; returns **false** otherwise. | | callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. Returns **true** if the operation is successful; returns **false** otherwise. |
**Example** **Example**
```js ```js
import featureAbility from '@ohos.ability.featureAbility'; import settings from '@ohos.settings';
// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.) // Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.)
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); settings.setValue(this.context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', (status) => {
let helper = featureAbility.acquireDataAbilityHelper(uri); console.log('Callback return whether value is set.');
// @ts-ignore
// The value of the data item is a string.
settings.setValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', (status) => {
console.log('Callback return whether value is set.');
}); });
``` ```
## settings.setValue ## settings.setValue<sup>10+</sup>
setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object): Promise\<boolean> setValue(context: Context, name: string, value: string): Promise\<boolean>
Sets the value for a data item. This API uses a promise to return the result. Sets the value for a data item. This API uses a promise to return the result.
**System API**: This is a system API. **Model restriction**: This API can be used only in the stage model.
**System capability**: SystemCapability.Applications.settings.Core **System capability**: SystemCapability.Applications.settings.Core
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | ------- | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | | context | Context | Yes | Application context.<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items| | name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
| value | object | Yes | Value of the data item. The value range varies by service. | | value | string | Yes | Value of the data item. The value range varies by service. |
**Return value** **Return value**
...@@ -247,18 +247,149 @@ Sets the value for a data item. This API uses a promise to return the result. ...@@ -247,18 +247,149 @@ Sets the value for a data item. This API uses a promise to return the result.
**Example** **Example**
```js ```js
import featureAbility from '@ohos.ability.featureAbility'; import settings from '@ohos.settings';
// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.) // Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.)
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); settings.setValue(this.context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100').then((status) => {
let helper = featureAbility.acquireDataAbilityHelper(uri); console.log('Callback return whether value is set.');
// @ts-ignore });
// The value of the data item is a string. ```
settings.setValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100').then((status) => {
console.log('Callback return whether value is set.'); ## setting.getValue<sup>10+</sup>
getValue(context: Context, name: string, callback: AsyncCallback\<string>): void
Obtains the value of a data item in the database. This API uses an asynchronous callback to return the result.
**Model restriction**: This API can be used only in the stage model.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| context | Context | Yes | Application context.<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br> - Existing data items in the database<br>- Custom data items|
| callback | AsyncCallback\<string> | Yes | Callback used to return the value of the data item. |
**Example**
```js
import settings from '@ohos.settings';
settings.getValue(this.context, settings.display.SCREEN_BRIGHTNESS_STATUS, (err, value) => {
if (err) {
console.error(`Failed to get the setting. ${err.message} `);
return;
}
console.log(`callback:value -> ${JSON.stringify(value)}`)
}); });
``` ```
## setting.getValue<sup>10+</sup>
getValue(context: Context, name: string): Promise\<string>
Obtains the value of a data item in the database. This API uses a promise to return the result.
**Model restriction**: This API can be used only in the stage model.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | ------------------------------------------------------------ |
| context | Context | Yes | Application context.<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br> - Existing data items in the database<br>- Custom data items|
**Return value**
| Type | Description |
| ---------------- | ----------------------------------- |
| Promise\<string> | Promise used to return the value of the data item.|
**Example**
```js
import settings from '@ohos.settings';
settings.getValue(this.context, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value) => {
console.log(`promise:value -> ${JSON.stringify(value)}`)
});
```
## settings.getValueSync<sup>10+</sup>
getValueSync(context: Context, name: string, defValue: string): string;
Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously.
**Model restriction**: This API can be used only in the stage model.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------- | ---- | ------------------------------------------------------------ |
| context | Context | Yes | Application context.<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
| defValue | string | Yes | Default value, which is returned when the value of a data item is not found in the database. Set this parameter as needed.|
**Return value**
| Type | Description |
| ------ | ---------------- |
| string | Value of the data item.|
**Example**
```js
import settings from '@ohos.settings';
// Obtain the value of SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database).
let value = settings.getValueSync(this.context, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
```
## settings.setValueSync<sup>10+</sup>
setValueSync(context: Context, name: string, value: string): boolean
Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously.
If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database.
**Model restriction**: This API can be used only in the stage model.
**System capability**: SystemCapability.Applications.settings.Core
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | ------------------------------------------------------------ |
| context | Context | Yes | Application context.<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
| value | string | Yes | Value of the data item. The value range varies by service. |
**Return value**
| Type | Description |
| ------- | ------------------------------------------------------------ |
| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
**Example**
```js
import settings from '@ohos.settings';
// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValueSync API will update the value of the data item.)
let ret = settings.setValueSync(this.context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100');
```
## settings.enableAirplaneMode ## settings.enableAirplaneMode
enableAirplaneMode(enable: boolean, callback: AsyncCallback\<void>): void enableAirplaneMode(enable: boolean, callback: AsyncCallback\<void>): void
...@@ -390,7 +521,7 @@ Obtains the URI of a data item. ...@@ -390,7 +521,7 @@ Obtains the URI of a data item.
```js ```js
// Obtain the URI of a data item. // Obtain the URI of a data item.
let urivar = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); let uriVar = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
``` ```
## setting.getURI<sup>(deprecated)</sup> ## setting.getURI<sup>(deprecated)</sup>
...@@ -401,7 +532,7 @@ Obtains the URI of a data item. This API uses an asynchronous callback to return ...@@ -401,7 +532,7 @@ Obtains the URI of a data item. This API uses an asynchronous callback to return
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. > This API is supported since API version 7 and deprecated since API version 9. No substitute API is provided.
**System capability**: SystemCapability.Applications.settings.Core **System capability**: SystemCapability.Applications.settings.Core
...@@ -428,7 +559,7 @@ Obtains the URI of a data item. This API uses a promise to return the result. ...@@ -428,7 +559,7 @@ Obtains the URI of a data item. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. > This API is supported since API version 7 and deprecated since API version 9. No substitute API is provided.
**System capability**: SystemCapability.Applications.settings.Core **System capability**: SystemCapability.Applications.settings.Core
...@@ -452,6 +583,91 @@ settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS).then((uri) => { ...@@ -452,6 +583,91 @@ settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS).then((uri) => {
}) })
``` ```
## settings.setValue<sup>(deprecated)</sup>
setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object, callback: AsyncCallback\<boolean>): void
Sets the value for a data item. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setValue()](#settingssetvalue10) instead.
**System API**: This is a system API.
**Model restriction**: This API can be used only in the FA model.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
| value | object | Yes | Value of the data item. The value range varies by service. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. Returns **true** if the operation is successful; returns **false** otherwise. |
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility';
// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.)
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri);
//@ts-ignore
// The value of the data item is a string.
settings.setValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', (status) => {
console.log('Callback return whether value is set.');
});
```
## settings.setValue<sup>(deprecated)</sup>
setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object): Promise\<boolean>
Sets the value for a data item. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setValue()](#settingssetvalue10-1) instead.
**System API**: This is a system API.
**Model restriction**: This API can be used only in the FA model.
**System capability**: SystemCapability.Applications.settings.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
| value | object | Yes | Value of the data item. The value range varies by service. |
**Return value**
| Type | Description |
| ----------------- | -------------------------------------------------- |
| Promise\<boolean> | Promise used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility';
// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.)
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri);
//@ts-ignore
// The value of the data item is a string.
settings.setValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100').then((status) => {
console.log('Callback return whether value is set.');
});
```
## setting.getValue<sup>(deprecated)</sup> ## setting.getValue<sup>(deprecated)</sup>
getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback\<object>): void getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback\<object>): void
...@@ -460,7 +676,7 @@ Obtains the value of a data item in the database. This API uses an asynchronous ...@@ -460,7 +676,7 @@ Obtains the value of a data item in the database. This API uses an asynchronous
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getValue()](#settinggetvalue10) instead.
**Model restriction**: This API can be used only in the FA model. **Model restriction**: This API can be used only in the FA model.
...@@ -468,11 +684,11 @@ Obtains the value of a data item in the database. This API uses an asynchronous ...@@ -468,11 +684,11 @@ Obtains the value of a data item in the database. This API uses an asynchronous
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | | dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br> - Existing data items in the database<br>- Custom data items| | name | string | Yes | Name of the target data item. Data items can be classified as follows:<br> - Existing data items in the database<br>- Custom data items|
| callback | AsyncCallback\<object> | Yes | Callback used to return the value of the data item. | | callback | AsyncCallback\<object> | Yes | Callback used to return the value of the data item. |
**Example** **Example**
...@@ -498,7 +714,7 @@ Obtains the value of a data item in the database. This API uses a promise to ret ...@@ -498,7 +714,7 @@ Obtains the value of a data item in the database. This API uses a promise to ret
> **NOTE** > **NOTE**
> >
> This API is supported since API version 7 and deprecated since API version 9. > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getValue()](#settinggetvalue10-1) instead.
**Model restriction**: This API can be used only in the FA model. **Model restriction**: This API can be used only in the FA model.
...@@ -506,10 +722,10 @@ Obtains the value of a data item in the database. This API uses a promise to ret ...@@ -506,10 +722,10 @@ Obtains the value of a data item in the database. This API uses a promise to ret
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | | dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br> - Existing data items in the database<br>- Custom data items| | name | string | Yes | Name of the target data item. Data items can be classified as follows:<br> - Existing data items in the database<br>- Custom data items|
**Return value** **Return value**
...@@ -537,7 +753,7 @@ Obtains the value of a data item. Unlike **getValue**, this API returns the resu ...@@ -537,7 +753,7 @@ Obtains the value of a data item. Unlike **getValue**, this API returns the resu
> **NOTE** > **NOTE**
> >
> This API is supported since API version 8 and deprecated since API version 9. > This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getValueSync()](#settingsgetvaluesync10) instead.
**Model restriction**: This API can be used only in the FA model. **Model restriction**: This API can be used only in the FA model.
...@@ -545,11 +761,11 @@ Obtains the value of a data item. Unlike **getValue**, this API returns the resu ...@@ -545,11 +761,11 @@ Obtains the value of a data item. Unlike **getValue**, this API returns the resu
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | | dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items| | name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
| defValue | string | Yes | Default value, which is returned when the value of a data item is not found in the database. Set this parameter as needed.| | defValue | string | Yes | Default value, which is returned when the value of a data item is not found in the database. Set this parameter as needed.|
**Return value** **Return value**
...@@ -578,7 +794,7 @@ If the specified data item exists in the database, the **setValueSync** method u ...@@ -578,7 +794,7 @@ If the specified data item exists in the database, the **setValueSync** method u
> **NOTE** > **NOTE**
> >
> This API is supported since API version 8 and deprecated since API version 9. > This API is supported since API version 8 and deprecated since API version 9. You are advised to use [setValueSync()](#settingssetvaluesync10) instead.
**Model restriction**: This API can be used only in the FA model. **Model restriction**: This API can be used only in the FA model.
...@@ -588,11 +804,11 @@ If the specified data item exists in the database, the **setValueSync** method u ...@@ -588,11 +804,11 @@ If the specified data item exists in the database, the **setValueSync** method u
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | | ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | | dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. |
| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items| | name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
| value | string | Yes | Value of the data item. The value range varies by service. | | value | string | Yes | Value of the data item. The value range varies by service. |
**Return value** **Return value**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册