提交 0f1000a6 编写于 作者: G Gloria

Update docs against 13915+14265++14716+13515

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 72b2d7eb
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
- [MissionSnapshot](js-apis-inner-application-missionSnapshot.md) - [MissionSnapshot](js-apis-inner-application-missionSnapshot.md)
- [ProcessData](js-apis-inner-application-processData.md) - [ProcessData](js-apis-inner-application-processData.md)
- [ProcessRunningInfo](js-apis-inner-application-processRunningInfo.md) - [ProcessRunningInfo](js-apis-inner-application-processRunningInfo.md)
- [ProcessRunningInformation](js-apis-inner-application-processRunningInformation.md) - [ProcessInformation](js-apis-inner-application-processInformation.md)
- [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md) - [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md)
- [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md) - [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md)
- [shellCmdResult](js-apis-inner-application-shellCmdResult.md) - [shellCmdResult](js-apis-inner-application-shellCmdResult.md)
...@@ -152,7 +152,6 @@ ...@@ -152,7 +152,6 @@
- [hapModuleInfo](js-apis-bundleManager-hapModuleInfo.md) - [hapModuleInfo](js-apis-bundleManager-hapModuleInfo.md)
- [launcherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md) - [launcherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)
- [metadata](js-apis-bundleManager-metadata.md) - [metadata](js-apis-bundleManager-metadata.md)
- [packInfo](js-apis-bundleManager-packInfo.md)
- [permissionDef](js-apis-bundleManager-permissionDef.md) - [permissionDef](js-apis-bundleManager-permissionDef.md)
- [remoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md) - [remoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)
- [shortcutInfo](js-apis-bundleManager-shortcutInfo.md) - [shortcutInfo](js-apis-bundleManager-shortcutInfo.md)
...@@ -185,7 +184,7 @@ ...@@ -185,7 +184,7 @@
- [@ohos.i18n (Internationalization)](js-apis-i18n.md) - [@ohos.i18n (Internationalization)](js-apis-i18n.md)
- [@ohos.intl (Internationalization)](js-apis-intl.md) - [@ohos.intl (Internationalization)](js-apis-intl.md)
- [@ohos.resourceManager (Resource Manager)](js-apis-resource-manager.md) - [@ohos.resourceManager (Resource Manager)](js-apis-resource-manager.md)
- Resource Scheduling - Background Tasks
- [@ohos.distributedMissionManager (Distributed Mission Management)](js-apis-distributedMissionManager.md) - [@ohos.distributedMissionManager (Distributed Mission Management)](js-apis-distributedMissionManager.md)
- [@ohos.reminderAgentManager (Reminder Agent Management)](js-apis-reminderAgentManager.md) - [@ohos.reminderAgentManager (Reminder Agent Management)](js-apis-reminderAgentManager.md)
- [@ohos.resourceschedule.backgroundTaskManager (Background Task Management)](js-apis-resourceschedule-backgroundTaskManager.md) - [@ohos.resourceschedule.backgroundTaskManager (Background Task Management)](js-apis-resourceschedule-backgroundTaskManager.md)
...@@ -211,7 +210,7 @@ ...@@ -211,7 +210,7 @@
- [@ohos.data.distributedDataObject (Distributed Data Object)](js-apis-data-distributedobject.md) - [@ohos.data.distributedDataObject (Distributed Data Object)](js-apis-data-distributedobject.md)
- [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md) - [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md)
- [@ohos.data.preferences (Preferences)](js-apis-data-preferences.md) - [@ohos.data.preferences (Preferences)](js-apis-data-preferences.md)
- [@ohos.data.relationalStore (ϵݿ)](js-apis-data-relationalStore.md) - [@ohos.data.relationalStore (RDB Store)](js-apis-data-relationalStore.md)
- [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md) - [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md)
- data/rdb - data/rdb
- [resultSet](js-apis-data-resultset.md) - [resultSet](js-apis-data-resultset.md)
...@@ -371,6 +370,7 @@ ...@@ -371,6 +370,7 @@
- [@ohos.statfs (statfs)](js-apis-statfs.md) - [@ohos.statfs (statfs)](js-apis-statfs.md)
- [@ohos.systemParameter (System Parameter)](js-apis-system-parameter.md) - [@ohos.systemParameter (System Parameter)](js-apis-system-parameter.md)
- [@ohos.usb (USB Management)](js-apis-usb-deprecated.md) - [@ohos.usb (USB Management)](js-apis-usb-deprecated.md)
- [@ohos.usbV9 (USB Management)](js-apis-usb.md)
- [@system.app (Application Context)](js-apis-system-app.md) - [@system.app (Application Context)](js-apis-system-app.md)
- [@system.battery (Battery Information)](js-apis-system-battery.md) - [@system.battery (Battery Information)](js-apis-system-battery.md)
- [@system.bluetooth (Bluetooth)](js-apis-system-bluetooth.md) - [@system.bluetooth (Bluetooth)](js-apis-system-bluetooth.md)
......
...@@ -26,7 +26,7 @@ For details, see [Permission Levels](../../security/accesstoken-overview.md#perm ...@@ -26,7 +26,7 @@ For details, see [Permission Levels](../../security/accesstoken-overview.md#perm
## distributedBundle.getRemoteAbilityInfo<sup>deprecated<sup> ## distributedBundle.getRemoteAbilityInfo<sup>deprecated<sup>
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundle)](js-apis-distributedBundle.md) instead. > This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundleManager)](js-apis-distributedBundleManager.md) instead.
getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback&lt;RemoteAbilityInfo&gt;): void; getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback&lt;RemoteAbilityInfo&gt;): void;
...@@ -55,7 +55,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -55,7 +55,7 @@ This is a system API and cannot be called by third-party applications.
## distributedBundle.getRemoteAbilityInfo<sup>deprecated<sup> ## distributedBundle.getRemoteAbilityInfo<sup>deprecated<sup>
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundle)](js-apis-distributedBundle.md) instead. > This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundleManager)](js-apis-distributedBundleManager.md) instead.
getRemoteAbilityInfo(elementName: ElementName): Promise&lt;RemoteAbilityInfo&gt; getRemoteAbilityInfo(elementName: ElementName): Promise&lt;RemoteAbilityInfo&gt;
...@@ -87,7 +87,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -87,7 +87,7 @@ This is a system API and cannot be called by third-party applications.
## distributedBundle.getRemoteAbilityInfos<sup>deprecated<sup> ## distributedBundle.getRemoteAbilityInfos<sup>deprecated<sup>
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundle)](js-apis-distributedBundle.md) instead. > This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundleManager)](js-apis-distributedBundleManager.md) instead.
getRemoteAbilityInfos(elementNames: Array&lt;ElementName&gt;, callback: AsyncCallback&lt;Array&lt;RemoteAbilityInfo&gt;&gt;): void; getRemoteAbilityInfos(elementNames: Array&lt;ElementName&gt;, callback: AsyncCallback&lt;Array&lt;RemoteAbilityInfo&gt;&gt;): void;
...@@ -116,7 +116,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -116,7 +116,7 @@ This is a system API and cannot be called by third-party applications.
## distributedBundle.getRemoteAbilityInfos<sup>deprecated<sup> ## distributedBundle.getRemoteAbilityInfos<sup>deprecated<sup>
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundle)](js-apis-distributedBundle.md) instead. > This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo(@ohos.bundle.distributedBundleManager)](js-apis-distributedBundleManager.md) instead.
getRemoteAbilityInfos(elementNames: Array&lt;ElementName&gt;): Promise&lt;Array&lt;RemoteAbilityInfo&gt;&gt; getRemoteAbilityInfos(elementNames: Array&lt;ElementName&gt;): Promise&lt;Array&lt;RemoteAbilityInfo&gt;&gt;
......
# @ohos.app.form.FormExtensionAbility (FormExtensionAbility) # @ohos.app.form.FormExtensionAbility (FormExtensionAbility)
The **FormExtensionAbility** module provides lifecycle callbacks invoked when a widget is created, destroyed, or updated. The **FormExtensionAbility** module provides APIs related to FormExtensionAbilities.
> **NOTE** > **NOTE**
> >
...@@ -19,7 +19,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; ...@@ -19,7 +19,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ | | ------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| context | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Yes | No | Context of the FormExtensionAbility. This context is inherited from [ExtensionContext](js-apis-inner-application-extensionContext.md).| | context | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Yes | No | Context of the FormExtensionAbility. This context is inherited from **ExtensionContext**.|
## onAddForm ## onAddForm
...@@ -33,7 +33,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been ...@@ -33,7 +33,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | | ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-want.md) | Yes | Want information related to the FormExtensionAbility, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.| | want | [Want](js-apis-application-want.md) | Yes | Want information related to the ExtensionAbility, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
**Return value** **Return value**
...@@ -45,19 +45,17 @@ Called to notify the widget provider that a **Form** instance (widget) has been ...@@ -45,19 +45,17 @@ Called to notify the widget provider that a **Form** instance (widget) has been
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData';
export default class MyFormExtensionAbility extends FormExtensionAbility { export default class MyFormExtensionAbility extends FormExtensionAbility {
onAddForm(want) { onAddForm(want) {
console.log('FormExtensionAbility onAddForm, want:' + want.abilityName); console.log('FormExtensionAbility onAddForm, want:' + want.abilityName);
let dataObj1 = { let dataObj1 = {
temperature: "11c", temperature:'11c',
"time": "11:00" 'time':'11:00'
}; };
let obj1 = formBindingData.createFormBindingData(dataObj1); let obj1 = formBindingData.createFormBindingData(dataObj1);
return obj1; return obj1;
} }
}; }
``` ```
## onCastToNormalForm ## onCastToNormalForm
...@@ -77,20 +75,18 @@ Called to notify the widget provider that a temporary widget has been converted ...@@ -77,20 +75,18 @@ Called to notify the widget provider that a temporary widget has been converted
**Example** **Example**
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility { export default class MyFormExtensionAbility extends FormExtensionAbility {
onCastToNormalForm(formId) { onCastToNormalForm(formId) {
console.log('FormExtensionAbility onCastToNormalForm, formId:' + formId); console.log('FormExtensionAbility onCastToNormalForm, formId:' + formId);
} }
}; }
``` ```
## onUpdateForm ## onUpdateForm
onUpdateForm(formId: string): void onUpdateForm(formId: string): void
Called to notify the widget provider that a widget has been updated. After obtaining the latest data, your application should call [updateForm](js-apis-app-form-formProvider.md#updateform) of **formProvider** to update the widget data. Called to notify the widget provider that a widget has been updated. After obtaining the latest data, your application should call **updateForm** of [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) to update the widget data.
**System capability**: SystemCapability.Ability.Form **System capability**: SystemCapability.Ability.Form
...@@ -103,24 +99,17 @@ Called to notify the widget provider that a widget has been updated. After obtai ...@@ -103,24 +99,17 @@ Called to notify the widget provider that a widget has been updated. After obtai
**Example** **Example**
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
export default class MyFormExtensionAbility extends FormExtensionAbility { export default class MyFormExtensionAbility extends FormExtensionAbility {
onUpdateForm(formId) { onUpdateForm(formId) {
console.log('FormExtensionAbility onUpdateForm, formId:' + formId); console.log('FormExtensionAbility onUpdateForm, formId:' + formId);
let obj2 = formBindingData.createFormBindingData({ let obj2 = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
temperature: "22c", this.context.updateForm(formId, obj2).then((data)=>{
time: "22:00"
});
formProvider.updateForm(formId, obj2).then((data) => {
console.log('FormExtensionAbility context updateForm, data:' + data); console.log('FormExtensionAbility context updateForm, data:' + data);
}).catch((error) => { }).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error); console.error('Operation updateForm failed. Cause: ' + error);});
}); }
} }
};
``` ```
## onChangeFormVisibility ## onChangeFormVisibility
...@@ -140,28 +129,21 @@ Called to notify the widget provider of the change of visibility. ...@@ -140,28 +129,21 @@ Called to notify the widget provider of the change of visibility.
**Example** **Example**
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; import formBindingData from '@ohos.app.form.formBindingData';
import formBindingData from '@ohos.app.form.formBindingData'
import formProvider from '@ohos.app.form.formProvider';
export default class MyFormExtensionAbility extends FormExtensionAbility { export default class MyFormExtensionAbility extends FormExtensionAbility {
onChangeFormVisibility(newStatus) { onChangeFormVisibility(newStatus) {
console.log('FormExtensionAbility onChangeFormVisibility, newStatus:' + newStatus); console.log('FormExtensionAbility onChangeFormVisibility, newStatus:' + newStatus);
let obj2 = formBindingData.createFormBindingData({ let obj2 = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
temperature: "22c",
time: "22:00" for (let key in newStatus) {
}); console.log('FormExtensionAbility onChangeFormVisibility, key:' + key + ', value=' + newStatus[key]);
this.context.updateForm(key, obj2).then((data)=>{
for (let key in newStatus) {
console.log('FormExtensionAbility onChangeFormVisibility, key:' + key + ", value=" + newStatus[key]);
formProvider.updateForm(key, obj2).then((data) => {
console.log('FormExtensionAbility context updateForm, data:' + data); console.log('FormExtensionAbility context updateForm, data:' + data);
}).catch((error) => { }).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error); console.error('Operation updateForm failed. Cause: ' + error);});
});
} }
} }
}; }
``` ```
## onFormEvent ## onFormEvent
...@@ -182,13 +164,11 @@ Called to instruct the widget provider to receive and process the widget event. ...@@ -182,13 +164,11 @@ Called to instruct the widget provider to receive and process the widget event.
**Example** **Example**
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; export default class MyFormExtension extends FormExtensionAbility {
export default class MyFormExtensionAbility extends FormExtensionAbility {
onFormEvent(formId, message) { onFormEvent(formId, message) {
console.log('FormExtensionAbility onFormEvent, formId:' + formId + ", message:" + message); console.log('FormExtensionAbility onFormEvent, formId:' + formId + ', message:' + message);
} }
}; }
``` ```
## onRemoveForm ## onRemoveForm
...@@ -208,13 +188,11 @@ Called to notify the widget provider that a **Form** instance (widget) has been ...@@ -208,13 +188,11 @@ Called to notify the widget provider that a **Form** instance (widget) has been
**Example** **Example**
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility { export default class MyFormExtensionAbility extends FormExtensionAbility {
onRemoveForm(formId) { onRemoveForm(formId) {
console.log('FormExtensionAbility onRemoveForm, formId:' + formId); console.log('FormExtensionAbility onRemoveForm, formId:' + formId);
} }
}; }
``` ```
## onConfigurationUpdate ## onConfigurationUpdate
...@@ -234,13 +212,11 @@ Called when the configuration of the environment where the ability is running is ...@@ -234,13 +212,11 @@ Called when the configuration of the environment where the ability is running is
**Example** **Example**
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; class MyFormExtensionAbility extends FormExtensionAbility {
export default class MyFormExtensionAbility extends FormExtensionAbility {
onConfigurationUpdate(config) { onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, config:' + JSON.stringify(config)); console.log('onConfigurationUpdate, config:' + JSON.stringify(config));
} }
}; }
``` ```
## onAcquireFormState ## onAcquireFormState
...@@ -260,15 +236,13 @@ Called when the widget provider receives the status query result of a widget. By ...@@ -260,15 +236,13 @@ Called when the widget provider receives the status query result of a widget. By
**Example** **Example**
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formInfo from '@ohos.app.form.formInfo'; import formInfo from '@ohos.app.form.formInfo';
class MyFormExtensionAbility extends FormExtensionAbility {
export default class MyFormExtensionAbility extends FormExtensionAbility {
onAcquireFormState(want) { onAcquireFormState(want) {
console.log('FormExtensionAbility onAcquireFormState, want:' + want); console.log('FormExtensionAbility onAcquireFormState, want:' + want);
return formInfo.FormState.UNKNOWN; return formInfo.FormState.UNKNOWN;
} }
}; }
``` ```
## onShareForm ## onShareForm
...@@ -296,16 +270,14 @@ Called by the widget provider to receive shared widget data. ...@@ -296,16 +270,14 @@ Called by the widget provider to receive shared widget data.
**Example** **Example**
```ts ```ts
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; class MyFormExtensionAbility extends FormExtensionAbility {
export default class MyFormExtensionAbility extends FormExtensionAbility {
onShareForm(formId) { onShareForm(formId) {
console.log('FormExtensionAbility onShareForm, formId:' + formId); console.log('FormExtensionAbility onShareForm, formId:' + formId);
let wantParams = { let wantParams = {
"temperature": "20", 'temperature':'20',
"time": "2022-8-8 09:59", 'time':'2022-8-8 09:59',
}; };
return wantParams; return wantParams;
} }
}; }
``` ```
# @ohos.application.context (Context)
The **Context** module provides all level-2 module APIs for developers to export.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import context from '@ohos.application.context'
```
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| AbilityContext | Read Only | [AbilityContext](js-apis-ability-context.md) | No | Level-2 module **AbilityContext**. |
| AbilityStageContext | Read Only | [AbilityStageContext](js-apis-inner-application-abilityStageContext.md) | No | Level-2 module **AbilityStageContext**.|
| ApplicationContext | Read Only | [ApplicationContext](js-apis-inner-application-applicationContext.md) | No | Level-2 module **ApplicationContext**.|
| BaseContext | Read Only | [BaseContext](js-apis-inner-application-baseContext.md) | No | Level-2 module **BaseContext**.|
| Context | Read Only | [Context](js-apis-inner-application-context.md) | No | Level-2 module **Context**.|
| ExtensionContext | Read Only | [ExtensionContext](js-apis-inner-application-extensionContext.md) | No | Level-2 module **ExtensionContext**.|
| FormExtensionContext | Read Only | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | No | Level-2 module **FormExtensionContext**.|
| EventHub | Read Only | [EventHub](js-apis-inner-application-eventHub.md) | No | Level-2 module **EventHub**.|
| PermissionRequestResult | Read Only | [PermissionRequestResult](js-apis-inner-application-permissionRequestResult.md) | No | Level-2 module **PermissionRequestResult**.|
**Example**
```ts
let abilityContext: context.AbilityContext;
let abilityStageContext: context.AbilityStageContext;
let applicationContext: context.ApplicationContext;
let baseContext: context.BaseContext;
let context: context.Context;
let extensionContext: context.ExtensionContext;
let formExtensionContext: context.FormExtensionContext;
let eventHub: context.EventHub;
let permissionRequestResult: context.PermissionRequestResult;
```
# @ohos.application.ExtensionAbility (ExtensionAbility)
The **ExtensionAbility** module manages the ExtensionAbility lifecycle and context, such as creating and destroying an ExtensionAbility, and dumping client information.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import ExtensionAbility from '@ohos.application.ExtensionAbility';
```
## ExtensionAbility.onConfigurationUpdated
onConfigurationUpdated(newConfig: Configuration): void;
Called when the configuration of the environment where the ability is running is updated.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| newConfig | [Configuration](js-apis-application-configuration.md) | Yes| New configuration.|
**Example**
```ts
class MyExtensionAbility extends ExtensionAbility {
onConfigurationUpdated(config) {
console.log('onConfigurationUpdated, config:' + JSON.stringify(config));
}
}
```
## ExtensionAbility.onMemoryLevel
onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system has decided to adjust the memory level. For example, this API can be used when there is not enough memory to run as many background processes as possible.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| level | [AbilityConstant.MemoryLevel](js-apis-application-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.|
**Example**
```ts
class MyExtensionAbility extends ExtensionAbility {
onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level));
}
}
```
...@@ -21,9 +21,9 @@ The **ApplicationInfo** module defines the application information. A system app ...@@ -21,9 +21,9 @@ The **ApplicationInfo** module defines the application information. A system app
| icon | string | Yes | No | Application icon. | | icon | string | Yes | No | Application icon. |
| iconId | number | Yes | No | ID of the application icon. | | iconId | number | Yes | No | ID of the application icon. |
| process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used. | | process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used. |
| permissions | Array\<string> | Yes | No | Permissions required for accessing the application. The permissions can be obtained by passing in **GET_APPLICATION_INFO_WITH_PERMISSION** to the **appFlags** parameter of [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).| | permissions | Array\<string> | Yes | No | Permissions required for accessing the application. The permissions can be obtained by passing in **GET_APPLICATION_INFO_WITH_PERMISSION** to [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).|
| codePath | string | Yes | No | Installation directory of the application. | | codePath | string | Yes | No | Installation directory of the application. |
| metadata | Map\<string, Array\<[Metadata](js-apis-bundleManager-metadata.md)>> | Yes | No | Metadata of the application. The information can be obtained by passing in **GET_APPLICATION_INFO_WITH_METADATA** to the **appFlags** parameter of [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).| | metadata | Map\<string, Array\<[Metadata](js-apis-bundleManager-metadata.md)>> | Yes | No | Metadata of the application. The information can be obtained by passing in **GET_APPLICATION_INFO_WITH_METADATA** to [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).|
| removable | boolean | Yes | No | Whether the application is removable. | | removable | boolean | Yes | No | Whether the application is removable. |
| accessTokenId | number | Yes | No | Access token ID of the application. | | accessTokenId | number | Yes | No | Access token ID of the application. |
| uid | number | Yes | No | UID of the application. | | uid | number | Yes | No | UID of the application. |
...@@ -32,3 +32,4 @@ The **ApplicationInfo** module defines the application information. A system app ...@@ -32,3 +32,4 @@ The **ApplicationInfo** module defines the application information. A system app
| descriptionResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Description resource of the application. | | descriptionResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Description resource of the application. |
| appDistributionType | string | Yes | No | Distribution type of the application signing certificate. The options are **app_gallery**, **enterprise**, **os_integration**, and **crowdtesting**. | | appDistributionType | string | Yes | No | Distribution type of the application signing certificate. The options are **app_gallery**, **enterprise**, **os_integration**, and **crowdtesting**. |
| appProvisionType | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**. | | appProvisionType | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**. |
| systemApp | boolean | Yes | No | Whether the application is a system application. |
...@@ -6,8 +6,6 @@ The **BundleInfo** module defines the bundle information. A system application c ...@@ -6,8 +6,6 @@ The **BundleInfo** module defines the bundle information. A system application c
> >
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## BundleInfo ## BundleInfo
**System capability**: SystemCapability.BundleManager.BundleFramework.Core **System capability**: SystemCapability.BundleManager.BundleFramework.Core
......
# ExtensionAbilityInfo # ExtensionAbilityInfo
The **ExtensionAbilityInfo** module defines the ExtensionAbility information. A system application can obtain its own or others' ExtensionAbility information through [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo). A third-party application can obtain its own ExtensionAbility information through [getBundleInfoForSelf](js-apis-bundleManager.md#bundlemanagergetbundleinfoforself). **GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY** must be passed in to the input parameter [bundleFlags](js-apis-bundleManager.md#bundleflag) to obtain the information. The **ExtensionAbilityInfo** module defines the ExtensionAbility information. A system application can obtain its own or others' ExtensionAbility information through [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo). A third-party application can obtain its own ExtensionAbility information through [getBundleInfoForSelf](js-apis-bundleManager.md#bundlemanagergetbundleinfoforself). The input parameter [bundleFlags](js-apis-bundleManager.md#bundleflag) must be set to **GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY**.
> **NOTE** > **NOTE**
> >
...@@ -18,7 +18,7 @@ The **ExtensionAbilityInfo** module defines the ExtensionAbility information. A ...@@ -18,7 +18,7 @@ The **ExtensionAbilityInfo** module defines the ExtensionAbility information. A
| labelId | number | Yes | No | ID of the ExtensionAbility label. | | labelId | number | Yes | No | ID of the ExtensionAbility label. |
| descriptionId | number | Yes | No | ID of the ExtensionAbility description. | | descriptionId | number | Yes | No | ID of the ExtensionAbility description. |
| iconId | number | Yes | No | ID of the ExtensionAbility icon. | | iconId | number | Yes | No | ID of the ExtensionAbility icon. |
| isVisible | boolean | Yes | No | Whether the ExtensionAbility can be called by other bundles. | | exported | boolean | Yes | No | Whether the ExtensionAbility can be called by other bundles. |
| extensionAbilityType | [ExtensionAbilityType](js-apis-bundleManager.md#extensionabilitytype) | Yes | No | Type of the ExtensionAbility. | | extensionAbilityType | [ExtensionAbilityType](js-apis-bundleManager.md#extensionabilitytype) | Yes | No | Type of the ExtensionAbility. |
| permissions | Array\<string> | Yes | No | Permissions required for other bundles to call the ExtensionAbility.| | permissions | Array\<string> | Yes | No | Permissions required for other bundles to call the ExtensionAbility.|
| applicationInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Yes | No | Application information. | | applicationInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Yes | No | Application information. |
......
# HapModuleInfo # HapModuleInfo
The **HapModuleInfo** module defines the HAP module information. A system application can obtain its own or others' HAP module information through [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo). A third-party application can obtain its own HAP module information through [getBundleInfoForSelf](js-apis-bundleManager.md#bundlemanagergetbundleinfoforself). **GET_BUNDLE_INFO_WITH_HAP_MODULE** must be passed in to the input parameter [bundleFlags](js-apis-bundleManager.md#bundleflag) to obtain the information. The **HapModuleInfo** module defines the HAP module information. A system application can obtain its own or others' HAP module information through [bundleManager.getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo). A third-party application can obtain its own HAP module information through [getBundleInfoForSelf](js-apis-bundleManager.md#bundlemanagergetbundleinfoforself). The input parameter [bundleFlags](js-apis-bundleManager.md#bundleflag) must be set to **GET_BUNDLE_INFO_WITH_HAP_MODULE**.
> **NOTE** > **NOTE**
> >
......
# PackInfo
The **PackInfo** module provides information in the **pack.info** file. The information can be obtained using [freeInstall.getBundlePackInfo](js-apis-freeInstall.md).
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## BundlePackInfo
**System API**: This is a system API.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| Name | Type | Readable| Writable| Description |
| -------- | --------------------------------------- | ---- | ---- | ------------------------- |
| packages | Array\<[PackageConfig](#packageconfig)> | Yes | No | Package configuration information in the **pack.info** file. |
| summary | [PackageSummary](#packagesummary) | Yes | No | Package summary information in the **pack.info** file.|
## PackageConfig
**System API**: This is a system API.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| Name | Type | Readable| Writable| Description |
| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
| deviceTypes | Array\<string> | Yes | No | Device types supported by the bundle. |
| name | string | Yes | No | Bundle name. |
| moduleType | string | Yes | No | Module type of the bundle. |
| deliveryWithInstall | boolean | Yes | No | Whether the HAP file will be installed when the user installs the bundle. The value **true** means that the HAP file will be automatically installed when the user installs the bundle, and **false** means the opposite.|
## PackageSummary
**System API**: This is a system API.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| Name | Type | Readable| Writable| Description |
| ------- | --------------------------------------------- | ---- | ---- | -------------------- |
| app | [BundleConfigInfo](#bundleconfiginfo) | Yes | No | Bundle configuration information. |
| modules | Array\<[ModuleConfigInfo](#moduleconfiginfo)> | Yes | No | Module configuration information of the bundle.|
## BundleConfigInfo
**System API**: This is a system API.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| Name | Type | Readable| Writable| Description |
| ---------- | ------------------- | ---- | ---- | -------------------------------------- |
| bundleName | string | Yes | No | Bundle name. It uniquely identifies an application.|
| version | [Version](#version) | Yes | No | Bundle version. |
## ModuleConfigInfo
**System API**: This is a system API.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| Name | Type | Readable| Writable| Description |
| ------------------ | ------------------------------------------------- | ---- | ---- | ---------------------------------- |
| mainAbility | string | Yes| No| Name of the main ability.|
| apiVersion | [ApiVersion](#apiversion) | Yes | No | API version of the module. |
| deviceType | Array\<string> | Yes | No | Device types supported by the module. |
| distro | [ModuleDistroInfo](#moduledistroinfo) | Yes | No | Distribution information of the module. |
| abilities | Array\<[ModuleAbilityInfo](#moduleabilityinfo)> | Yes | No | Ability information of the module. |
| extensionAbilities | Array\<[ExtensionAbilities](#extensionability)> | Yes | No | ExtensionAbility information of the module.|
## ModuleDistroInfo
**System API**: This is a system API.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| Name | Type | Readable| Writable| Description |
| ------------------- | ------- | ---- | ---- | ------------------------------------------------------------ |
| deliveryWithInstall | boolean | Yes | No | Whether the HAP file will be installed when the user installs the bundle. The value **true** means that the HAP file will be automatically installed when the user installs the bundle, and **false** means the opposite.|
| installationFree | boolean | Yes | No | Whether the HAP file supports the installation-free feature. The value **true** means that the HAP file supports the installation-free feature and meets installation-free constraints, and **false** means the opposite.|
| moduleName | string | Yes | No | Module name. |
| moduleType | string | Yes | No | Module type. |
## ModuleAbilityInfo
**System API**: This is a system API.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| Name | Type | Readable| Writable| Description |
| ------- | ------------------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| name | string | Yes | No | Name of the ability. The name must be unique in the bundle. |
| label | string | Yes | No | Name of the ability displayed to users. The value is a resource index to names in multiple languages.|
| visible | boolean | Yes | No | Whether the ability can be called by other bundles. The value **true** means that the ability can be called by other bundles, and **false** means the opposite.|
| forms | Array\<[AbilityFormInfo](#abilityforminfo)> | Yes | No | Widget information. |
## ExtensionAbility
**System API**: This is a system API.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| Name | Type | Readable| Writable| Description |
| ----- | ------------------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| name | string | Yes| No| Name of the ExtensionAbility.|
| forms | Array\<[AbilityFormInfo](#abilityforminfo)> | Yes | No | Widget information.|
## AbilityFormInfo
**System API**: This is a system API.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| Name | Type | Readable| Writable| Description |
| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
| name | string | Yes | No | Widget name. |
| type | string | Yes | No | Widget type. |
| updateEnabled | boolean | Yes | No | Whether the widget supports periodic update. The value **true** means that the widget supports periodic update, and **false** means the opposite.|
| scheduledUpdateTime | string | Yes | No | Scheduled time to update the widget. The value is in 24-hour format and accurate to the minute. |
| updateDuration | number | Yes | No | Interval to update the widget. The unit is 30 minutes. The value is a multiple of 30. A widget can be updated at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). If both are configured, **updateDuration** takes precedence.|
| supportDimensions | Array\<string> | Yes | No | Dimensions of the widget. The value can be **1\*2**, **2\*2**, **2\*4**, **4\*4**, or a combination of these options. At least one option must be specified when defining the widget.|
| defaultDimension | string | Yes | No | Default dimensions of the widget. The value must be available in the **supportDimensions** array of the widget.|
## ApiVersion
**System API**: This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| Name | Type | Readable| Writable| Description |
| ----------- | ------ | ---- | ---- | -------------------- |
| releaseType | string | Yes | No | Name of the API version. |
| compatible | number | Yes | No | Minimum API version.|
| target | number | Yes | No | Target API version. |
## Version
**System API**: This is a system API.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
| Name | Type | Readable| Writable| Description |
| ------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
| minCompatibleVersionCode | number | Yes | No | Minimum compatible version of the bundle. It is used to check whether the bundle is compatible with a version on other devices in the cross-device scenario. The value is a 32-bit non-negative integer.|
| name | string | Yes | No | Version number of the bundle visible to users. |
| code | number | Yes | No | Version number of the bundle used only for bundle management. The value is a 32-bit non-negative integer. It is used only to determine whether a version is later than another version. A larger value indicates a later version.|
# distributedBundle
The **distributedBundle** module provides APIs for managing distributed bundles.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import
```
import distributedBundle from '@ohos.bundle.distributedBundle';
```
## System Capability
SystemCapability.BundleManager.DistributedBundleFramework
## Required Permissions
| Permission | Permission Level | Description |
| ------------------------------------------ | ------------ | ------------------ |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | Permission to query information about all bundles.|
For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels).
## distributedBundle.getRemoteAbilityInfo
getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback\<RemoteAbilityInfo>): void;
Obtains information about the remote ability that matches the given element name. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.BundleManager.DistributedBundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name. |
| callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **RemoteAbilityInfo** object obtained. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
| ID| Error Message |
|----------|--------------------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. |
**Example**
```ts
try {
distributedBundle.getRemoteAbilityInfo(
{
deviceId: '1',
bundleName: 'com.example.application',
abilityName: 'MainAbility'
}, (err, data) => {
if (err) {
console.error('Operation failed:' + JSON.stringify(err));
} else {
console.info('Operation succeed:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## distributedBundle.getRemoteAbilityInfo
getRemoteAbilityInfo(elementName: ElementName): Promise\<RemoteAbilityInfo>;
Obtains information about the remote ability that matches the given element name. This API uses a promise to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.BundleManager.DistributedBundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | -------------------------------------------- | ---- | ----------------------- |
| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name.|
**Return value**
| Type | Description |
| ------------------------------------------------------------ | --------------------------------- |
| Promise\<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)> | Promise used to return the **RemoteAbilityInfo** object obtained.|
**Error codes**
For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
| ID| Error Message |
|----------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. |
**Example**
```ts
try {
distributedBundle.getRemoteAbilityInfo(
{
deviceId: '1',
bundleName: 'com.example.application',
abilityName: 'MainAbility'
}).then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => {
console.error('Operation failed:' + JSON.stringify(err));
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## distributedBundle.getRemoteAbilityInfo
getRemoteAbilityInfo(elementNames: Array\<ElementName>, callback: AsyncCallback\<Array\<RemoteAbilityInfo>>): void;
Obtains information about remote abilities that match the given element names. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.BundleManager.DistributedBundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10. |
| callback | AsyncCallback\<Array\<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)>> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of **RemoteAbilityInfo** objects obtained. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
| ID| Error Message |
|----------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. |
**Example**
```ts
try {
distributedBundle.getRemoteAbilityInfo(
[
{
deviceId: '1',
bundleName: 'com.example.application1',
abilityName: 'MainAbility1'
},
{
deviceId: '1',
bundleName: 'com.example.application2',
abilityName: 'MainAbility'
}
], (err, data) => {
if (err) {
console.error('Operation failed:' + JSON.stringify(err));
} else {
console.info('Operation succeed:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## distributedBundle.getRemoteAbilityInfo
getRemoteAbilityInfo(elementNames: Array\<ElementName>): Promise\<Array\<RemoteAbilityInfo>>;
Obtains information about remote abilities that match the given element names and locales. This API uses a promise to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.BundleManager.DistributedBundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | --------------------------------------------------- | ---- | ----------------------- |
| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10.|
**Return value**
| Type | Description |
| ------------------------------------------------------------ | --------------------------------- |
| Promise\<Array<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)>> | Promise used to return the array of **RemoteAbilityInfo** objects obtained.|
**Error codes**
For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
| ID| Error Message |
|----------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. |
**Example**
```ts
try {
distributedBundle.getRemoteAbilityInfo(
[
{
deviceId: '1',
bundleName: 'com.example.application',
abilityName: 'MainAbility'
},
{
deviceId: '1',
bundleName: 'com.example.application2',
abilityName: 'MainAbility'
}
]).then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => {
console.error('Operation failed:' + JSON.stringify(err));
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## distributedBundle.getRemoteAbilityInfo
getRemoteAbilityInfo(elementName: ElementName, locale: string, callback: AsyncCallback\<RemoteAbilityInfo>): void;
Obtains information about the remote ability that matches the given element name and locale. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.BundleManager.DistributedBundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name. |
| locale | string |Yes| Target locale.|
| callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **RemoteAbilityInfo** object obtained. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
| ID| Error Message |
|----------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. |
**Example**
```ts
try {
distributedBundle.getRemoteAbilityInfo(
{
deviceId: '1',
bundleName: 'com.example.application',
abilityName: 'MainAbility'
}, 'zh-Hans-CN', (err, data) => {
if (err) {
console.error('Operation failed:' + JSON.stringify(err));
} else {
console.info('Operation succeed:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## distributedBundle.getRemoteAbilityInfo
getRemoteAbilityInfo(elementName: ElementName, locale: string): Promise\<RemoteAbilityInfo>;
Obtains information about the remote ability that matches the given element name and locale. This API uses a promise to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.BundleManager.DistributedBundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | -------------------------------------------- | ---- | ----------------------- |
| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name.|
| locale | string |Yes| Target locale.|
**Return value**
| Type | Description |
| ------------------------------------------------------------ | --------------------------------- |
| Promise\<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)> | Promise used to return the **RemoteAbilityInfo** object obtained.|
**Error codes**
For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
| ID| Error Message |
|----------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. |
**Example**
```ts
try {
distributedBundle.getRemoteAbilityInfo(
{
deviceId: '1',
bundleName: 'com.example.application',
abilityName: 'MainAbility'
}, 'zh-Hans-CN').then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => {
console.error('Operation failed:' + JSON.stringify(err));
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## distributedBundle.getRemoteAbilityInfo
getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string, callback: AsyncCallback\<Array\<RemoteAbilityInfo>>): void;
Obtains information about remote abilities that match the given element names and locales. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.BundleManager.DistributedBundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10. |
| locale | string |Yes| Target locale.|
| callback | AsyncCallback\<Array\<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)>> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of **RemoteAbilityInfo** objects obtained. Otherwise, **err** is an error object.|
**Error codes**
For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
| ID | Error Message |
|---------------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. |
**Example**
```ts
try {
distributedBundle.getRemoteAbilityInfo(
[
{
deviceId: '1',
bundleName: 'com.example.application1',
abilityName: 'MainAbility1'
},
{
deviceId: '1',
bundleName: 'com.example.application2',
abilityName: 'MainAbility'
}
], 'zh-Hans-CN', (err, data) => {
if (err) {
console.error('Operation failed:' + JSON.stringify(err));
} else {
console.info('Operation succeed:' + JSON.stringify(data));
}
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
## distributedBundle.getRemoteAbilityInfo
getRemoteAbilityInfo(elementNames: Array\<ElementName>, locale: string): Promise\<Array\<RemoteAbilityInfo>>;
Obtains information about remote abilities that match the given element names and locales. This API uses a promise to return the result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.BundleManager.DistributedBundleFramework
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | --------------------------------------------------- | ---- | ----------------------- |
| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10.|
| locale | string |Yes| Target locale.|
**Return value**
| Type | Description |
| ------------------------------------------------------------ | --------------------------------- |
| Promise\<Array<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)>> | Promise used to return the array of **RemoteAbilityInfo** objects obtained.|
**Error codes**
For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
| ID| Error Message |
|----------|-------------------------|
| 17700001 | The specified bundle name is not found. |
| 17700003 | The specified ability name is not found. |
| 17700007 | The specified device ID is not found. |
| 17700027 | The distributed service is not running. |
**Example**
```ts
try {
distributedBundle.getRemoteAbilityInfo(
[
{
deviceId: '1',
bundleName: 'com.example.application',
abilityName: 'MainAbility'
},
{
deviceId: '1',
bundleName: 'com.example.application2',
abilityName: 'MainAbility'
}
], 'zh-Hans-CN').then(data => {
console.info('Operation succeed:' + JSON.stringify(data));
}).catch(err => {
console.error('Operation failed:' + JSON.stringify(err));
});
} catch (err) {
console.error('Operation failed:' + JSON.stringify(err));
}
```
# ProcessRunningInformation # ProcessInformation
The **ProcessRunningInformation** module defines the running information of a process. The **ProcessInformation** module defines the running information of a process.
> **NOTE** > **NOTE**
> >
...@@ -8,13 +8,13 @@ The **ProcessRunningInformation** module defines the running information of a pr ...@@ -8,13 +8,13 @@ The **ProcessRunningInformation** module defines the running information of a pr
## How to Use ## How to Use
The process running information is obtained through [getProcessRunningInformation](js-apis-application-appManager.md#appmanagergetprocessrunninginformation9) in **appManager**. The process information is obtained by calling [getRunningProcessInformation](js-apis-app-ability-appManager.md#appmanagergetrunningprocessinformation9) of the **appManager** module.
```ts ```ts
import appManager from '@ohos.application.appManager'; import appManager from '@ohos.app.ability.appManager';
appManager.getProcessRunningInformation((error, data) => { appManager.getRunningProcessInformation((error, data) => {
console.log("error: " + error.code + " data: " + JSON.stringify(data)); console.log('error: ' + error.code + ' data: ' + JSON.stringify(data));
}); });
``` ```
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
The **ProcessRunningInfo** module defines the running information of a process. The **ProcessRunningInfo** module defines the running information of a process.
> **NOTE** > **NOTE**
> - The APIs provided by this module are deprecated since API version 9. You are advised to use [ProcessRunningInformation<sup>9+</sup>](js-apis-inner-application-processRunningInformation.md) instead. > - The APIs provided by this module are deprecated since API version 9. You are advised to use [ProcessInformation<sup>9+</sup>](js-apis-inner-application-processInformation.md) instead.
> - The initial APIs of this module are supported since API version 8. > - The initial APIs of this module are supported since API version 8.
## Attributes ## Attributes
......
# Security Label
The **secuityLabel** module provides APIs to manage file data security levels, including obtaining and setting file data security levels.
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import securityLabel from '@ohos.securityLabel';
```
## Usage
Before using the APIs provided by this module to perform operations on a file or directory, obtain the path of the application sandbox as follows:
```js
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
let path = '';
context.getFilesDir().then((data) => {
path = data;
})
```
## securityLabel.setSecurityLabel
setSecurityLabel(path:string, type:dataLevel):Promise&lt;void&gt;
Sets the security label for a file in asynchronous mode. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | -------------------------------------------- |
| path | string | Yes | File path. |
| type | dataLevel | Yes | File security level, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.|
**Return value**
| Type | Description |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise used to return the result. An empty value will be returned.|
**Example**
```js
securityLabel.setSecurityLabel(path, "s0").then(function(){
console.info("setSecurityLabel successfully");
}).catch(function(error){
console.info("setSecurityLabel failed with error:" + error);
});
```
## securityLabel.setSecurityLabel
setSecurityLabel(path:string, type:dataLevel, callback: AsyncCallback&lt;void&gt;):void
Sets the security label for a file in asynchronous mode. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | -------------------------------------------- |
| path | string | Yes | File path. |
| type | dataLevel | Yes | File security level, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
securityLabel.setSecurityLabel(path, "s0", function(error){
console.info("setSecurityLabel:" + JSON.stringify(error));
});
```
## securityLabel.setSecurityLabelSync
setSecurityLabelSync(path:string, type:dataLevel):void
Sets the security label for a file in synchronous mode.
**System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | -------------------------------------------- |
| path | string | Yes | File path. |
| type | dataLevel | Yes | File security level, which can be **s0**, **s1**, **s2**, **s3**, or **s4**.|
**Example**
```js
securityLabel.setSecurityLabelSync(path, "s0");
```
## securityLabel.getSecurityLabel
getSecurityLabel(path:string):Promise&lt;string&gt;
Obtains the security label of a file in asynchronous mode. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| path | string | Yes | File path.|
**Return value**
| Type | Description |
| --------------------- | ------------ |
| Promise&lt;string&gt; | Promise used to return the security label obtained.|
**Example**
```js
securityLabel.getSecurityLabel(path).then(function(type){
console.log("getSecurityLabel successfully:" + type);
}).catch(function(err){
console.log("getSecurityLabel failed with error:" + err);
});
```
## securityLabel.getSecurityLabel
getSecurityLabel(path:string, callback:AsyncCallback&lt;string&gt;): void
Obtains the security label of a file in asynchronous mode. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------------- |
| path | string | Yes | File path. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the security label obtained.|
**Example**
```js
securityLabel.getSecurityLabel(path, function(err, type){
console.log("getSecurityLabel successfully:" + type);
});
```
## securityLabel.getSecurityLabelSync
getSecurityLabelSync(path:string):string
Obtains the security label of a file in synchronous mode.
**System capability**: SystemCapability.FileManagement.File.FileIO
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| path | string | Yes | File path.|
**Return value**
| Type | Description |
| ------ | ------------ |
| string | Security label obtained.|
**Example**
```js
let result = securityLabel.getSecurityLabelSync(path);
console.log("getSecurityLabel successfully:" + result);
```
# @ohos.storageStatistics (App Storage Statistics)
The **storageStatistics** module provides APIs for obtaining storage space information, including the space of built-in and plug-in memory cards, space occupied by different types of data, and space of application data.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import storageStatistics from "@ohos.storageStatistics";
```
## storageStatistics.getTotalSizeOfVolume
getTotalSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;
Asynchronously obtains the total size of the specified volume. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description|
| ---------- | ------ | ---- | ---- |
| volumeUuid | string | Yes | UUID of the volume.|
**Return value**
| Type | Description |
| --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the total size of the volume.|
**Example**
```js
let uuid = "";
storageStatistics.getTotalSizeOfVolume(uuid).then(function(number){
console.info("getTotalSizeOfVolume successfully:"+ number);
}).catch(function(err){
console.info("getTotalSizeOfVolume failed with error:"+ err);
});
```
## storageStatistics.getTotalSizeOfVolume
getTotalSizeOfVolume(volumeUuid: string, callback: AsyncCallback&lt;number&gt;): void
Asynchronously obtains the total size of the specified volume. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| volumeUuid | string | Yes | UUID of the volume. |
| callback | callback: AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total size of the volume.|
**Example**
```js
let uuid = "";
storageStatistics.getTotalSizeOfVolume(uuid, function(error, number){
// Do something.
console.info("getTotalSizeOfVolume successfully:"+ number);
});
```
## storageStatistics.getFreeSizeOfVolume
getFreeSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;
Asynchronously obtains the available space of the specified volume. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description|
| ---------- | ------ | ---- | ---- |
| volumeUuid | string | Yes | UUID of the volume.|
**Return value**
| Type | Description |
| --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the available space of the volume.|
**Example**
```js
let uuid = "";
storageStatistics.getFreeSizeOfVolume(uuid).then(function(number){
console.info("getFreeSizeOfVolume successfully:"+ number);
}).catch(function(err){
console.info("getFreeSizeOfVolume failed with error:"+ err);
});
```
## storageStatistics.getFreeSizeOfVolume
getFreeSizeOfVolume(volumeUuid: string, callback: AsyncCallback&lt;number&gt;): void
Asynchronously obtains the available space of the specified volume. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | ---------------------------- |
| volumeUuid | string | Yes | UUID of the volume. |
| callback | callback: AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the volume.|
**Example**
```js
let uuid = "";
storageStatistics.getFreeSizeOfVolume(uuid, function(error, number){
// Do something.
console.info("getFreeSizeOfVolume successfully:"+ number);
});
```
## storageStatistics.getBundleStats<sup>9+</sup>
getBundleStats(packageName: string): Promise&lt;BundleStats&gt;
Asynchronously obtains space information of an application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | -------- |
| packageName | string | Yes | Bundle name of the application.|
**Return value**
| Type | Description |
| ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained.|
**Example**
```js
let packageName = "";
storageStatistics.getBundleStats(packageName).then(function(BundleStats){
console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats));
}).catch(function(err){
console.info("getBundleStats failed with error:"+ err);
});
```
## storageStatistics.getBundleStats<sup>9+</sup>
getBundleStats(packageName: string, callback: AsyncCallback&lt;BundleStats&gt;): void
Asynchronously obtains space information of an application. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| packageName | string | Yes | Bundle name of the application.|
| callback | callback: AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained.|
**Example**
```js
let packageName = "";
storageStatistics.getBundleStats(packageName, function(error, BundleStats){
// Do something.
console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats));
});
```
## storageStatistics.getCurrentBundleStats<sup>9+</sup>
getCurrentBundleStats(): Promise&lt;BundleStats&gt;
Asynchronously obtains space information of the current third-party application. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**Return value**
| Type | Description |
| ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the space information obtained. |
**Example**
```js
let bundleStats = storageStatistics.getCurrentBundleStats();
console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
```
## storageStatistics.getCurrentBundleStats<sup>9+</sup>
getCurrentBundleStats(callback: AsyncCallback&lt;BundleStats&gt;): void
Asynchronously obtains space information of the current third-party application. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback: AsyncCallback&lt;[BundleStats](#bundlestats)&gt; | Yes | Callback invoked to return the space information obtained. |
**Example**
```js
storageStatistics.getCurrentBundleStats(function(error, bundleStats){
// Do something.
console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
});
```
## BundleStats<sup>9+</sup>
### Attributes
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
| Name | Type | Description |
| --------- | ------ | -------------- |
| appSize | number | Size of the application. |
| cacheSize | number | Cache size of the application. |
| dataSize | number | Total data size of the application.|
## storageStatistics.getTotalSize<sup>9+</sup>
getTotalSize(): Promise&lt;number&gt;
Obtains the total space of the built-in memory card. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Return value**
| Type | Description |
| --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the total space of the built-in memory card. |
**Example**
```js
let number = storageStatistics.getTotalSize();
console.info("getTotalSize successfully:"+ JSON.stringify(number));
```
## storageStatistics.getTotalSize<sup>9+</sup>
getTotalSize(callback: AsyncCallback&lt;number&gt;): void
Obtains the total space of the built-in memory card. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------------------------ | ---- | ------------------------ |
| callback | callback: AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total space of the built-in memory card.|
**Example**
```js
storageStatistics.getTotalSize(function(error, number){
// Do something.
console.info("getTotalSize successfully:"+ JSON.stringify(number));
});
```
## storageStatistics.getFreeSize<sup>9+</sup>
getFreeSize(): Promise&lt;number&gt;
Obtains the available space of the built-in memory card. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Return value**
| Type | Description |
| --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the available space of the built-in memory card.|
**Example**
```js
let number = storageStatistics.getFreeSize();
console.info("getFreeSize successfully:"+ JSON.stringify(number));
```
## storageStatistics.getFreeSize<sup>9+</sup>
getFreeSize(callback: AsyncCallback&lt;number&gt;): void
Obtains the available space of the built-in memory card. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------- |
| callback | callback: AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in memory card.|
**Example**
```js
storageStatistics.getFreeSize(function(error, number){
// Do something.
console.info("getFreeSize successfully:"+ JSON.stringify(number));
});
```
## storageStatistics.getSystemSize<sup>9+</sup>
getSystemSize(): Promise&lt;number&gt;
Asynchronously obtains the system space. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Return value**
| Type | Description |
| --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the system space obtained.|
**Example**
```js
storageStatistics.getSystemSize().then(function(number){
console.info("getSystemSize successfully:"+ number);
}).catch(function(err){
console.info("getSystemSize failed with error:"+ err);
});
```
## storageStatistics.getSystemSize<sup>9+</sup>
getSystemSize(callback: AsyncCallback&lt;number&gt;): void
Asynchronously obtains the system space. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| callback | callback: AsyncCallback&lt;number&gt; | Yes | Callback used to return the system space obtained.|
**Example**
```js
storageStatistics.getSystemSize(function(error, number){
// Do something.
console.info("getSystemSize successfully:"+ number);
});
```
## storageStatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId? : number): Promise&lt;StorageStats&gt;
Asynchronously obtains the space occupied by each type of user data. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description|
| ---------- | ------ | ---- | ---- |
| userId | number | No | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried.|
**Return value**
| Type | Description |
| --------------------- | ---------------- |
| Promise&lt;[StorageStats](#storagestats)&gt; | Promise used to return the information obtained.|
**Example**
```js
let userId = 1;
storageStatistics.getUserStorageStats(userId).then(function(StorageStats){
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
}).catch(function(err){
console.info("getUserStorageStats failed with error:"+ err);
});
```
## storageStatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId: number, callback: AsyncCallback&lt;StorageStats&gt;): void
Asynchronously obtains the space occupied by each type of user data. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| userId | number | No | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried. |
| callback | callback: AsyncCallback&lt;[StorageStats](#storagestats)&gt; | Yes | Callback invoked to return the information obtained.|
**Example**
```js
let userId = 1;
storageStatistics.getUserStorageStats(userId, function(error, StorageStats){
// Do something.
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
});
```
## StorageStats<sup>9+</sup>
### Attributes
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
This is a system API and cannot be called by third-party applications.
| Name | Type | Description |
| --------- | ------ | -------------- |
| total | number | Total space of the built-in memory card. |
| audio | number | Space occupied by audio data. |
| video | number | Space occupied by video data.|
| image | number | Space occupied by image data. |
| file | number | Space occupied by files. |
| app | number | Space occupied by application data.|
# Volume Management
The volumeManager module provides APIs for volume and disk management, including obtaining volume information, mounting or unmounting volumes, partitioning disks, and formatting volumes.
> **NOTE**<br>
>
> - The initial APIs of this module are supported since API version 9.
> - API version 9 is a canary version for trial use. The APIs of this version may be unstable.
> - The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import
```js
import volumemanager from "@ohos.volumeManager";
```
## volumemanager.getAllVolumes
getAllVolumes(): Promise&lt;Array&lt;Volume&gt;&gt;
Asynchronously obtains information about all available volumes. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Return value**
| Type | Description |
| ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)[]&gt; | Promise used to return the execution result.|
**Example**
```js
volumemanager.getAllVolumes().then(function(volumes){
// Do something.
});
```
## volumemanager.getAllVolumes
getAllVolumes(callback: AsyncCallback&lt;Array&lt;Volume&gt;&gt;): void
Asynchronously obtains information about all available volumes. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback: AsyncCallback&lt;[Volume](#volume)[]&gt; | Yes | Callback invoked to return the volume information obtained.|
**Example**
```js
let uuid = "";
volumemanager.getAllVolumes(function(error, volumes){
// Do something
});
```
## volumemanager.mount
mount(volumeId: string): Promise&lt;boolean&gt;
Asynchronously mounts a volume. This API uses a promise to return the result.
**Required permissions**: ohos.permission.MOUNT_UNMOUNT_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description|
| -------- | ------ | ---- | ---- |
| volumeId | string | Yes | Volume ID.|
**Return value**
| Type | Description |
| ---------------------- | ---------- |
| Promise&lt;boolean&gt; | Promise used to return the execution result.|
**Example**
```js
let volumeId = "";
volumemanager.mount(volumeId).then(function(flag){
// Do something
});
```
## volumemanager.mount
mount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void
Asynchronously obtains the available space of the specified volume. This API uses a callback to return the result.
**Required permissions**: ohos.permission.MOUNT_UNMOUNT_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | Yes | Volume ID. |
| callback | callback: AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the execution result.|
**Example**
```js
let volumeId = "";
volumemanager.mount(volumeId, function(error, flag){
// Do something
});
```
## volumemanager.unmount
unmount(volumeId: string): Promise&lt;boolean&gt;
Asynchronously unmounts a volume. This API uses a promise to return the result.
**Required permissions**: ohos.permission.MOUNT_UNMOUNT_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description|
| -------- | ------ | ---- | ---- |
| volumeId | string | Yes | Volume ID.|
**Return value**
| Type | Description |
| ---------------------- | ---------- |
| Promise&lt;boolean&gt; | Promise used to return the execution result.|
**Example**
```js
let volumeId = "";
volumemanager.unmount(volumeId).then(function(flag){
// Do something
});
```
## volumemanager.unmount
unmount(volumeId: string, callback: AsyncCallback&lt;boolean&gt;): void
Asynchronously unmounts a volume. This API uses a callback to return the result.
**Required permissions**: ohos.permission.MOUNT_UNMOUNT_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------- |
| volumeId | string | Yes | Volume ID. |
| callback | callback: AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the execution result.|
**Example**
```js
let volumeId = "";
volumemanager.unmount(volumeId, function(error, flag){
// Do something
});
```
## volumemanager.getVolumeByUuid
getVolumeByUuid(uuid: string): Promise&lt;Volume&gt;
Asynchronously obtains volume information based on the universally unique identifier (UUID). This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description|
| -------- | ------ | ---- | ---- |
| uuid | string | Yes | UUID of the volume.|
**Return value**
| Type | Description |
| ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)&gt; | Promise used to return the volume information obtained.|
**Example**
```js
let uuid = "";
volumemanager.getVolumeByUuid(uuid).then(function(volume) {
console.info("getVolumeByUuid successfully:" + JSON.stringify(volume));
}).catch(function(error){
console.info("getVolumeByUuid failed with error:"+ error);
});
```
## volumemanager.getVolumeByUuid
getVolumeByUuid(uuid: string, callback: AsyncCallback&lt;Volume&gt;): void
Asynchronously obtains volume information based on the UUID. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------- |
| uuid | string | Yes | UUID of the volume. |
| callback | callback: AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained.|
**Example**
```js
let uuid = "";
volumemanager.getVolumeByUuid(uuid, (error, volume) => {
// Do something.
});
```
## volumemanager.getVolumeById
getVolumeById(volumeId: string): Promise&lt;Volume&gt;
Asynchronously obtains volume information based on the volume ID. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory | Description|
| -------- | ------ | ---- | ---- |
| volumeId | string | Yes | Volume ID.|
**Return value**
| Type | Description |
| ---------------------------------- | -------------------------- |
| Promise&lt;[Volume](#volume)&gt; | Promise used to return the volume information obtained.|
**Example**
```js
let volumeId = "";
volumemanager.getVolumeById(volumeId).then(function(volume) {
console.info("getVolumeById successfully:" + JSON.stringify(volume));
}).catch(function(error){
console.info("getVolumeById failed with error:"+ error);
});
```
## volumemanager.getVolumeById
getVolumeById(volumeId: string, callback: AsyncCallback&lt;Volume&gt;): void
Asynchronously obtains volume information based on the volume ID. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- |
| volumeId | string | Yes | Volume ID. |
| callback | callback:AsyncCallback&lt;[Volume](#volume)&gt; | Yes | Callback invoked to return the volume information obtained. |
**Example**
```js
let volumeId = "";
volumemanager.getVolumeById(volumeId, (error, volume) => {
// Do something.
});
```
## volumemanager.setVolumeDescription
setVolumeDescription(uuid: string, description: string): Promise&lt;void&gt;
Asynchronously sets the volume description based on the UUID. This API uses a promise to return the result.
**Required permissions**: ohos.permission.MOUNT_UNMOUNT_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description|
| --------- | ------ | ---- | ---- |
| uuid | string | Yes | UUID of the volume.|
| description | string | Yes | Volume description.|
**Return value**
| Type | Description |
| ---------------------- | -------------------------- |
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
```js
let uuid = "";
let description = "";
volumemanager.setVolumeDescription(uuid, description).then(function() {
console.info("setVolumeDescription successfully");
}).catch(function(error){
console.info("setVolumeDescription failed with error:"+ error);
});
```
## volumemanager.setVolumeDescription
setVolumeDescription(uuid: string, description: string, callback: AsyncCallback&lt;void&gt;): void
Asynchronously sets the volume description based on the UUID. This API uses a callback to return the result.
**Required permissions**: ohos.permission.MOUNT_UNMOUNT_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | ---------------- |
| uuid | string | Yes | UUID of the volume. |
| description | string | Yes | Volume description. |
| callback | callback: AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result.|
**Example**
```js
let uuid = "";
let description = "";
volumemanager.setVolumeDescription(uuid, description, (error, bool) => {
// Do something.
});
```
## volumemanager.format
format(volumeId: string, fsType: string): Promise&lt;void&gt;
Asynchronously formats a volume. This API uses a promise to return the result.
**Required permissions**: ohos.permission.MOUNT_FORMAT_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description|
| ----------- | ------ | ---- | ---- |
| volumeId | string | Yes | Volume ID.|
| fsType | string | Yes | File system type.|
**Return value**
| Type | Description |
| ---------------------- | ---------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let volumeId = "";
let fsType = "";
volumemanager.format(volumeId, fsType).then(function() {
console.info("format successfully");
}).catch(function(error){
console.info("format failed with error:"+ error);
});
```
## volumemanager.format
format(volumeId: string, fsType: string, callback: AsyncCallback&lt;void&gt;): void
Asynchronously formats a volume. This API uses a callback to return the result.
**Required permissions**: ohos.permission.MOUNT_FORMAT_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- |
| volumeId | string | Yes | Volume ID. |
| fsType | string | Yes | File system type.|
| callback | callback: AsyncCallback&lt;void&gt; | Yes | Called after the volume is formatted. |
**Example**
```js
let volumeId = "";
let fsType = "";
volumemanager.format(volumeId, fsType, (error, bool) => {
// Do something.
});
```
## volumemanager.partition
partition(diskId: string, type: number): Promise&lt;void&gt;
Asynchronously partitions a disk. This API uses a promise to return the result.
**Required permissions**: ohos.permission.MOUNT_FORMAT_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description|
| ----------- | ------ | ---- | ---- |
| diskId | string | Yes | ID of the disk to which the volume belongs.|
| type | number | Yes | Partition type. |
**Return value**
| Type | Description |
| --------------------- | ----------------------- |
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
```js
let diskId = "";
let type = 0;
volumemanager.partition(diskId, type).then(function() {
console.info("partition successfully");
}).catch(function(error){
console.info("partition failed with error:"+ error);
});
```
## volumemanager.partition
partition(diskId: string, type: number, callback: AsyncCallback&lt;void&gt;): void
Asynchronously partitions a disk. This API uses a callback to return the result.
**Required permissions**: ohos.permission.MOUNT_FORMAT_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.Volume
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ---------------- |
| diskId | string | Yes | ID of the disk to which the volume belongs. |
| type | number | Yes | Partition type. |
| callback | callback: AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Example**
```js
let diskId = "";
let type = 0;
volumemanager.partition(diskId, type, (error, bool) => {
// Do something.
});
```
## Volume
**System capability**: SystemCapability.FileManagement.StorageService.Volume
### Attributes
| Name | Type | Description |
| ----------- | ------- | -------------------- |
| id | string | Volume ID. |
| uuid | string | UUID of the volume. |
| diskId | string | ID of the disk to which the volume belongs. |
| description | string | Description of the volume. |
| removable | boolean | Whether the volume is a removable storage device.|
| state | number | Volume state. |
| path | string | Mount address of the volume. |
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
- Resource Management - Resource Management
- [I18N Error Codes](errorcode-i18n.md) - [I18N Error Codes](errorcode-i18n.md)
- [Resource Manager Error Codes](errorcode-resource-manager.md) - [Resource Manager Error Codes](errorcode-resource-manager.md)
- Resource Scheduling - Background Tasks
- [backgroundTaskManager Error Codes](errorcode-backgroundTaskMgr.md) - [backgroundTaskManager Error Codes](errorcode-backgroundTaskMgr.md)
- [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) - [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md)
- [workScheduler Error Codes](errorcode-workScheduler.md) - [workScheduler Error Codes](errorcode-workScheduler.md)
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
- [DeviceUsageStatistics Error Codes](errorcode-DeviceUsageStatistics.md) - [DeviceUsageStatistics Error Codes](errorcode-DeviceUsageStatistics.md)
- Customization Management - Customization Management
- [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) - [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md)
- Language Base Class Library - Utils
- [Utils Error Codes](errorcode-utils.md) - [Utils Error Codes](errorcode-utils.md)
- Test - Test
- [UiTest Error Codes](errorcode-uitest.md) - [UiTest Error Codes](errorcode-uitest.md)
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
- Access Control - Access Control
- [Access Control (Permission) Overview](accesstoken-overview.md) - [Access Control (Permission) Overview](accesstoken-overview.md)
- [Permission Application Guide](accesstoken-guidelines.md) - [Permission Application Guide](accesstoken-guidelines.md)
- [Permission Verification Guide](permission-verify-guidelines.md) - [API Access Permission Verification](permission-verify-guidelines.md)
- [App Permission List](permission-list.md) - [Application Permission List](permission-list.md)
- User Authentication - User Authentication
- [User Authentication Overview](userauth-overview.md) - [User Authentication Overview](userauth-overview.md)
- [User Authentication Development](userauth-guidelines.md) - [User Authentication Development](userauth-guidelines.md)
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
- Certificate - Certificate
- [Certificate Overview](cert-overview.md) - [Certificate Overview](cert-overview.md)
- [Certificate Development](cert-guidelines.md) - [Certificate Development](cert-guidelines.md)
- hapsigner - hapsigner
- [hapsigner Overview](hapsigntool-overview.md) - [hapsigner Overview](hapsigntool-overview.md)
- [hapsigner Guide](hapsigntool-guidelines.md) - [hapsigner Guide](hapsigntool-guidelines.md)
- [HarmonyAppProvision Configuration File](app-provision-structure.md) - [HarmonyAppProvision Configuration File](app-provision-structure.md)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册