diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md index 4e37d4be279a2acc092617c9bc69723d2c924d9f..fc223a653ce0e202bdec3fae3b1822e98a2a3f70 100644 --- a/en/application-dev/reference/apis/js-apis-Bundle.md +++ b/en/application-dev/reference/apis/js-apis-Bundle.md @@ -1,6 +1,7 @@ -# Bundle Module (JavaScript SDK APIs) +# Bundle -> **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > API version 9 is a canary version for trial use. The APIs of this version may be unstable. ## Modules to Import @@ -15,11 +16,11 @@ SystemCapability.BundleManager.BundleFramework ## Required Permissions -| Required Permissions | Permission Level | Description | -| ---------------------------------------- | ------------ | --------- | -| ohos.permission.GET_BUNDLE_INFO | normal | Permission to query information about the current application.| +| Required Permissions | Permission Level | Description | +| ------------------------------------------ | ------------ | ------------------ | +| ohos.permission.GET_BUNDLE_INFO | normal | Permission to query information about the current application. | | ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to query information about all applications.| -| ohos.permission.INSTALL_BUNDLE | system_core | Permission to install or uninstall applications. | +| ohos.permission.INSTALL_BUNDLE | system_core | Permission to install or uninstall applications. | ## bundle.getApplicationInfo @@ -69,7 +70,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId) getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\): void -Obtains the application information based on a given bundle name. This API uses an asynchronous callback to return the result. +Obtains the application information of the specified user based on a given bundle name. This API uses an asynchronous callback to return the result. **Required permissions** @@ -143,9 +144,9 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => { ## bundle.getAllBundleInfo -getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise\> +getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise> -Obtains the information of all available bundles of a specified user in the system. This API uses a promise to return the result. +Obtains the information of all available bundles of the specified user in the system. This API uses a promise to return the result. **Required permissions** @@ -166,7 +167,7 @@ SystemCapability.BundleManager.BundleFramework | Type | Description | | --------------------------- | -------------------------- | -| Promise\> | Promise used to return the information of all available bundles.| +| Promise> | Promise used to return the information of all available bundles.| **Example** @@ -185,7 +186,7 @@ bundle.getAllBundleInfo(bundleFlag, userId) ## bundle.getAllBundleInfo -getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback\>): void +getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback>): void Obtains the information of all available bundles in the system. This API uses an asynchronous callback to return the result. @@ -220,9 +221,9 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => { ## bundle.getAllBundleInfo -getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback\>): void +getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback>): void -Obtains the information of all available bundles in the system. This API uses an asynchronous callback to return the result. +Obtains the information of all available bundles of the specified user in the system. This API uses an asynchronous callback to return the result. **Required permissions** @@ -238,7 +239,7 @@ SystemCapability.BundleManager.BundleFramework | ---------- | --------------------------------- | ---- | --------------------------------------- | | bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | -| callback | AsyncCallback\> | Yes | Callback used to return the information of all available bundles. | +| callback | AsyncCallback> | Yes | Callback used to return the information of all available bundles. | **Example** @@ -343,7 +344,7 @@ bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => { getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\): void -Obtains the bundle information based on a given bundle name. This API uses an asynchronous callback to return the result. +Obtains the bundle information based on a given bundle name and bundle options. This API uses an asynchronous callback to return the result. **Required permissions** @@ -718,10 +719,6 @@ isAbilityEnabled(info: AbilityInfo): Promise\ Checks whether the ability that matches a given **AbilityInfo** object is enabled. This API uses a promise to return the result. -**Required permissions** - -None - **System capability** SystemCapability.BundleManager.BundleFramework @@ -759,10 +756,6 @@ isAbilityEnabled(info : AbilityInfo, callback : AsyncCallback\): void Checks whether the ability that matches a given **AbilityInfo** object is enabled. This API uses an asynchronous callback to return the result. -**Required permissions** - -None - **System capability** SystemCapability.BundleManager.BundleFramework @@ -796,10 +789,6 @@ isApplicationEnabled(bundleName: string): Promise\ Checks whether an application is enabled based on a given bundle name. This API uses a promise to return the result. -**Required permissions** - -None - **System capability** SystemCapability.BundleManager.BundleFramework @@ -834,10 +823,6 @@ isApplicationEnabled(bundleName: string, callback : AsyncCallback\): vo Checks whether an application is enabled based on a given bundle name. This API uses an asynchronous callback to return the result. -**Required permissions** - -None - **System capability** SystemCapability.BundleManager.BundleFramework @@ -911,9 +896,13 @@ bundle.queryAbilityByWant(want, bundleFlags, userId) ## bundle.queryAbilityByWant -queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback\>): void +queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback>): void -Obtains the ability information based on a given want. This API uses an asynchronous callback to return the result. +Obtains the ability information of the specified user based on a given want. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO **System capability** @@ -923,7 +912,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ---------------------------------- | ---- | ------------------------------------- | -| want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | +| want | [Want](js-apis-application-Want.md)| Yes | Want that contains the bundle name. | | bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| | userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | callback | AsyncCallback> | Yes | Callback used to return the ability information. | @@ -952,6 +941,10 @@ queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback> | Yes | Callback used to return the ability information. | @@ -1127,7 +1120,7 @@ Obtains the [PixelMap](js-apis-image.md) of the icon corresponding to a given bu **Required permissions** -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO **System capability** @@ -1166,7 +1159,7 @@ Obtains the [PixelMap](js-apis-image.md) of the icon corresponding to a given bu **Required permissions** -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO **System capability** @@ -1203,7 +1196,7 @@ Obtains the Extension ability information based on a given want. This API uses a **Required permissions** -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO **System capability** @@ -1214,7 +1207,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | -------------- | ------ | ---- | ---------------------------------------- | | want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | -| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| +| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0. | | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** @@ -1246,11 +1239,11 @@ bundle.queryExtensionAbilityInfosByWant(want, extensionFlags, userId) queryExtensionAbilityInfosByWant(want: Want, extensionFlags: number, userId: number, callback: AsyncCallback>): void -Obtains the Extension ability information based on a given want. This API uses an asynchronous callback to return the result. +Obtains the Extension ability information of the specified user based on a given want. This API uses an asynchronous callback to return the result. **Required permissions** -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO **System capability** @@ -1258,12 +1251,12 @@ SystemCapability.BundleManager.BundleFramework **Parameters** -| Name | Type | Mandatory | Description | -| -------------- | ---------------------------------------- | ---- | ---------------------------------------- | -| want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | -| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| -| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | -| callback | AsyncCallback> | Yes | Callback used to return the Extension ability information. | +| Name | Type | Mandatory| Description | +| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | +| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0. | +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback> | Yes | Callback used to return the Extension ability information. | **Example** @@ -1301,8 +1294,8 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | -------------- | ---------------------------------------- | ---- | ---------------------------------------- | -| want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | -| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| +| want | [Want](js-apis-application-Want.md) | Yes | Want that contains the bundle name. | +| extensionFlags | number | Yes | Extension ability information to be returned. The default value is **0**. The value must be greater than or equal to 0. | | callback | AsyncCallback> | Yes | Callback used to return the Extension ability information. | **Example** @@ -1369,7 +1362,7 @@ Enumerates bundle flags. | GET_ABILITY_INFO_SYSTEMAPP_ONLY8+ | 0x00000080 | Obtains the ability information of system applications.| | GET_ABILITY_INFO_WITH_DISABLE8+ | 0x00000100 | Obtains information about disabled abilities. | | GET_APPLICATION_INFO_WITH_DISABLE8+ | 0x00000200 | Obtains information about disabled applications. | -| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information. | +| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information. | ## BundleOptions @@ -1403,10 +1396,10 @@ Enumerates display orientations. | Name | Type | Description | | ------------- | ---- | ------------- | -| UNSPECIFIED | None | The system automatically determines the display orientation. | +| UNSPECIFIED | None | Unspecified display orientation. | | LANDSCAPE | None | Landscape orientation. | | PORTRAIT | None | Portrait orientation. | -| FOLLOW_RECENT | None | The page ability orientation is the same as that of the nearest ability in the stack.| +| FOLLOW_RECENT | None | Orientation same as that of the nearest ability in the stack.| ## LaunchMode @@ -1438,7 +1431,7 @@ Enumerates Extension ability types. | Name | Type | Description | | ------------------------------ | ---- | ------------------------- | -| FORM9+ | 0 | Form included. | +| FORM9+ | 0 | Form (widget) included. | | WORK_SCHEDULER9+ | 1 | Work scheduler included.| | INPUT_METHOD9+ | 2 | Input method included. | | SERVICE9+ | 3 | Service included. | @@ -1484,3 +1477,4 @@ Enumerates permission grant states. | ------------------ | ---- | ---- | | PERMISSION_DENIED | -1 | Permission denied.| | PERMISSION_GRANTED | 0 | Permission granted. | + diff --git a/en/application-dev/reference/apis/js-apis-zlib.md b/en/application-dev/reference/apis/js-apis-zlib.md index 1192097ac4b6daa8b88331ae09fb98d6c8697384..cf3427a1922cf69f83453cda0a506e0568187fbe 100644 --- a/en/application-dev/reference/apis/js-apis-zlib.md +++ b/en/application-dev/reference/apis/js-apis-zlib.md @@ -1,6 +1,11 @@ # Zip +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## Constraints + None ## Modules to Import @@ -9,18 +14,19 @@ import zlib from '@ohos.zlib'; ``` ## zlib.zipFile -zipFile(inFile:string, outFile:string, options: Options): Promise\ +zipFile(inFile:string, outFile:string, options: Options): Promise<void> + Zips a file. This API uses a promise to return the result. **System capability**: SystemCapability.BundleManager.Zlib **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ----------------------------------- | ---- | ------------------------------------------- | -| inFile | string | Yes | Path of the folder or file to zip. | -| outFile | string | Yes | Path of the zipped file. The file name extension is .zip.| -| options | [Options](#options)| No | Optional parameters for the zip operation. | +| Name | Type | Mandatory| Description | +| ------- | ------------------- | ---- | ------------------------------------------------------------ | +| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md) and [Stage Model](js-apis-application-context.md).| +| outFile | string | Yes | Path of the zipped file. The file name extension is .zip. | +| options | [Options](#options) | No | Optional parameters for the zip operation. | **Return value** @@ -36,17 +42,14 @@ Zips a file. This API uses a promise to return the result. import zlib from '@ohos.zlib' var inFile = "/xxx/filename.xxx"; var outFile = "/xxx/xxx.zip"; -var options = {}; -options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; -options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; -options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; +var options = { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, + memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY +}; zlib.zipFile(inFile, outFile, options).then((data) => { - if (data == zlib.ErrorCode.ERROR_CODE_OK) { - console.log("zipFile OK"); - } else { - console.log("zipFile NG"); - } + console.log("zipFile result: " + data); }).catch((err)=>{ console.log("catch((err)=>" + err); }); @@ -60,17 +63,14 @@ zlib.zipFile(inFile, outFile, options).then((data) => { import zlib from '@ohos.zlib' var inFile = "/xxx/xxx"; var outFile = "/xxx/xxx.zip"; -var options = {}; -options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; -options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; -options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; - -zlib.zipFile(inFile , unzipDir, options).then((data) => { - if (data == zlib.ErrorCode.ERROR_CODE_OK) { - console.log("zipFile OK"); - } else { - console.log("zipFile NG"); - } +var options = { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, + memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY +}; + +zlib.zipFile(inFile , outFile, options).then((data) => { + console.log("zipFile result: " + data); }).catch((err)=>{ console.log("catch((err)=>" + err); }); @@ -78,7 +78,7 @@ zlib.zipFile(inFile , unzipDir, options).then((data) => { ## zlib.unzipFile -unzipFile(inFile:string, outFile:string, options: Options): Promise\ +unzipFile(inFile:string, outFile:string, options: Options): Promise<void> Unzips a file. This API uses a promise to return the result. @@ -86,11 +86,11 @@ Unzips a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ----------------------------------- | ---- | ----------------------------------- | -| inFile | string | Yes | Path of the file to unzip. The file name extension is .zip.| -| outFile | string | Yes | Path of the unzipped file. | -| options | [Options](#options)| No | Optional parameters for the unzip operation. | +| Name | Type | Mandatory| Description | +| ------- | ------------------- | ---- | ------------------------------------------------------------ | +| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md) and [Stage Model](js-apis-application-context.md).| +| outFile | string | Yes | Path of the unzipped file. | +| options | [Options](#options) | No | Optional parameters for the unzip operation. | **Return value** @@ -106,61 +106,67 @@ import zlib from '@ohos.zlib' var inFile = "/xx/xxx.zip"; var outFile = "/xxx"; -var options = {}; -options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; -options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; -options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; - +let options = { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, + memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY +}; zlib.unzipFile(inFile, outFile, options).then((data) => { - if (data == zlib.ErrorCode.ERROR_CODE_OK) { - console.log("unzipFile OK"); - } else { - console.log("unzipFile NG"); - } + console.log("unzipFile result: " + data); }).catch((err)=>{ console.log("catch((err)=>" + err); }) ``` -## options +## Options -| Name | Description | -| --------------------------- | ------------------------------------------------------------ | -| level?: CompressLeve | See [zip.CompressLevel](#zipcompresslevel). | -| memLevel?: MemLevel | See [zip.MemLevel](#zipmemlevel) | -| strategy?: CompressStrategy | See [zip.CompressStrategy](#zipcompressstrategy) | +**System capability**: SystemCapability.BundleManager.Zlib + +| Name | Type | Mandatory| Description | +| -------- | ---------------- | ---- | --------------------------------------------------------- | +| level | CompressLeve | No | See [zip.CompressLevel](#zipcompresslevel). | +| memLevel | MemLevel | No | See [zip.MemLevel](#zipmemlevel). | +| strategy | CompressStrategy | No | See [zip.CompressStrategy](#zipcompressstrategy).| ## zip.MemLevel -| Name | Description | -| ----------------- | -------------------------------- | -| MEM_LEVEL_MIN | Minimum memory used by the **zip** API during compression.| -| MEM_LEVEL_MAX | Maximum memory used by the **zip** API during compression.| -| MEM_LEVEL_DEFAULT | Default memory used by the **zip** API during compression.| +**System capability**: SystemCapability.BundleManager.Zlib + +| Name | Value | Description | +| ----------------- | ---- | -------------------------------- | +| MEM_LEVEL_MIN | 1 | Minimum memory used by the **zip** API during compression.| +| MEM_LEVEL_MIN | 9 | Maximum memory used by the **zip** API during compression.| +| MEM_LEVEL_DEFAULT | 8 | Default memory used by the **zip** API during compression.| + +## zip.CompressLevel -## Zip.CompressLevel +**System capability**: SystemCapability.BundleManager.Zlib -| Name | Description | -| --------------------------------------- | ----------------- | -| COMPRESS_LEVEL_NO_COMPRESSION : 0 | Compress level 0 that indicates uncompressed.| -| COMPRESS_LEVEL_BEST_SPEED : 1 | Compression level 1 that gives the best speed. | -| COMPRESS_LEVEL_BEST_COMPRESSION :9 | Compression level 9 that gives the best compression. | -| COMPRESS_LEVEL_DEFAULT_COMPRESSION : -1| Default compression level. | +| Name | Value | Description | +| ---------------------------------- | ---- | ----------------- | +| COMPRESS_LEVEL_NO_COMPRESSION | 0 | Compress level 0 that indicates uncompressed.| +| COMPRESS_LEVEL_BEST_SPEED | 1 | Compression level 1 that gives the best speed. | +| COMPRESS_LEVEL_BEST_COMPRESSION | 9 | Compression level 9 that gives the best compression. | +| COMPRESS_LEVEL_DEFAULT_COMPRESSION | -1 | Default compression level. | -## Zip.CompressStrategy +## zip.CompressStrategy -| Name | Description | -| -------------------------------------- | ------------------------ | -| COMPRESS_STRATEGY_DEFAULT_STRATEGY : 0 | Default compression strategy. | -| COMPRESS_STRATEGY_FILTERED : 1 | Filtered compression strategy.| -| COMPRESS_STRATEGY_HUFFMAN_ONLY : 2 | Huffman coding compression strategy. | -| COMPRESS_STRATEGY_RLE : 3 | RLE compression strategy. | -| COMPRESS_STRATEGY_FIXED : 4 | Fixed compression strategy. | +**System capability**: SystemCapability.BundleManager.Zlib + +| Name | Value | Description | +| ---------------------------------- | ---- | ------------------------ | +| COMPRESS_STRATEGY_DEFAULT_STRATEGY | 0 | Default compression strategy. | +| COMPRESS_STRATEGY_FILTERED | 1 | Filtered compression strategy.| +| COMPRESS_STRATEGY_HUFFMAN_ONLY | 2 | Huffman coding compression strategy. | +| COMPRESS_STRATEGY_RLE | 3 | RLE compression strategy. | +| COMPRESS_STRATEGY_FIXED | 4 | Fixed compression strategy. | ## zip.ErrorCode -| Name | Description | -| -------------------- | ------------ | -| ERROR_CODE_OK: 0 | The API is successfully called.| -| ERROR_CODE_ERRNO:- 1 | Failed to call the API.| +**System capability**: SystemCapability.BundleManager.Zlib + +| Name | Value | Description | +| ---------------- | ---- | ------------ | +| ERROR_CODE_OK | 0 | The API is successfully called.| +| ERROR_CODE_ERRNO | -1 | Failed to call the API.|