From ee8ad91d6d2380866c86cf068d8c314969a30d17 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Mon, 21 Aug 2023 15:57:56 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../reference/apis/Readme-EN.md | 1 - ...ppAccount-authorizationExtensionAbility.md | 70 --- .../apis/js-apis-distributedDeviceManager.md | 206 ++++----- .../reference/apis/js-apis-file-fs.md | 2 +- .../reference/apis/js-apis-fileAccess.md | 212 +++------ .../reference/apis/js-apis-nfcTag.md | 42 +- .../apis/js-apis-photoAccessHelper.md | 424 +++++++++++++++++- .../reference/apis/js-apis-secureElement.md | 15 +- .../reference/apis/js-apis-userFileManager.md | 424 +++++++++++++++++- .../apis/js-apis-useriam-userauth.md | 2 +- .../changelogs-account_os_account.md | 56 +++ .../OpenHarmony_4.0.10.1/changelogs-cert.md | 6 +- .../changelogs-wifiManager.md | 47 ++ 13 files changed, 1148 insertions(+), 359 deletions(-) delete mode 100644 en/application-dev/reference/apis/js-apis-appAccount-authorizationExtensionAbility.md create mode 100644 en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-account_os_account.md create mode 100644 en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-wifiManager.md diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 49b419c555..c73bec55b4 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -421,7 +421,6 @@ - Account Management - [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md) - - [@ohos.account.appAccount.AuthorizationExtensionAbility (App AuthorizationExtensionAbility)](js-apis-appAccount-authorizationExtensionAbility.md) - [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md) - [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md) diff --git a/en/application-dev/reference/apis/js-apis-appAccount-authorizationExtensionAbility.md b/en/application-dev/reference/apis/js-apis-appAccount-authorizationExtensionAbility.md deleted file mode 100644 index dd40fcecca..0000000000 --- a/en/application-dev/reference/apis/js-apis-appAccount-authorizationExtensionAbility.md +++ /dev/null @@ -1,70 +0,0 @@ -# @ohos.account.appAccount.AuthorizationExtensionAbility (App AuthorizationExtensionAbility) - -The **AuthorizationExtensionAbility** module provides APIs for implementing authorization to app accounts based on the ExtensionAbility framework. - -> **NOTE** -> -> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. - -## Modules to Import - -```ts -import AuthorizationExtensionAbility, { AuthorizationRequest, AuthorizationCallback } from '@ohos.account.appAccount.AuthorizationExtensionAbility'; -``` - -## AuthorizationRequest - -Defines the app account authorization request. - -**System API**: This is a system API. - -**System capability**: SystemCapability.Account.AppAccount - -| Name | Type | Readable| Writable| Description | -| --------- | ------------------------------- | ---- | ---- | ------------------------------------ | -| callerUid | number | Yes | No | UID of the caller.| -| parameters | [appAccount.AccountCapabilityRequest](js-apis-appAccount.md#accountcapabilityrequest10) | Yes | No | Service parameters.| - -## AuthorizationCallback - -Provides callbacks to be invoked during the app account authorization. - -**System API**: This is a system API. - -**System capability**: SystemCapability.Account.AppAccount - -| Name | Type | Readable| Writable| Description | -| --------- | ------------------------------- | ---- | ---- | ------------------------------------ | -| onResult | AsyncCallback<[appAccount.AccountCapabilityResponse](js-apis-appAccount.md#accountcapabilityresponse10), { [key: string]: object }> | Yes | No | Callback invoked to return the authorization result.| - -## AuthorizationExtensionAbility.onStartAuthorization - -onStartAuthorization(request: AuthorizationRequest, callback: AuthorizationCallback): void - -Called when an authorization request is received. - -**System API**: This is a system API. - -**System capability**: SystemCapability.Account.AppAccount - -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ----------------------- | -| request | [AuthorizationRequest](#authorizationrequest) | Yes | Authorization request information.| -| callback | [AuthorizationCallback](#authorizationcallback) | Yes | Authorization callback object.| - -**Example** - -```ts -class MyAuthorizationExtensionAbility extends AuthorizationExtensionAbility { - onStartAuthorization(request: AuthorizationRequest, callback: AuthorizationCallback) { - console.log('onStartAuthorization, callerUid: ' + request.callerUid + ', parameters: ' + request.parameters); - let response = { - name: 'xxxx', - scopes: ['xxx', 'xxx'] - }; - callback.onResult(null, response); - } -}; -``` diff --git a/en/application-dev/reference/apis/js-apis-distributedDeviceManager.md b/en/application-dev/reference/apis/js-apis-distributedDeviceManager.md index 7e3d76ec2e..e1b55f7e18 100644 --- a/en/application-dev/reference/apis/js-apis-distributedDeviceManager.md +++ b/en/application-dev/reference/apis/js-apis-distributedDeviceManager.md @@ -13,7 +13,7 @@ Applications can call the APIs to: > **NOTE** > -> - The initial APIs of this module are supported since API version 10. 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 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -39,9 +39,9 @@ Creates a **DeviceManager** instance. The **DeviceManager** instance is the entr **Return value** - | Name | Description | - | ------------------------------------------- | --------- | - | [DeviceManager](#devicemanager) | **DeviceManager** instance created.| +| Name | Description | +| ------------------------------------------- | --------- | +| [DeviceManager](#devicemanager) | **DeviceManager** instance created.| **Example** @@ -97,7 +97,7 @@ Represents the basic information about a distributed device. | ---------------------- | ------------------------- | ---- | -------- | | deviceId | string | Yes | Unique ID of the device. The value is the udid-hash (hash value of the UDID) and appid encrypted using SHA-256.| | deviceName | string | Yes | Device name. | -| deviceType | number | Yes | Device type. | +| deviceType | string | Yes | Device type. | | networkId | string | No | Network ID of the device. | ## DeviceStateChange @@ -129,9 +129,9 @@ Obtains all trusted devices synchronously. **Return value** - | Name | Description | - | ------------------------------------------- | --------- | - | Array<[DeviceBasicInfo](#devicebasicinfo)> | List of trusted devices obtained.| +| Name | Description | +| ------------------------------------------- | --------- | +| Array<[DeviceBasicInfo](#devicebasicinfo)> | List of trusted devices obtained.| **Error codes** @@ -163,9 +163,9 @@ Obtains all trusted devices. This API uses an asynchronous callback to return th **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | --------------------- | - | callback | AsyncCallback<Array<[DeviceBasicInfo](#devicebasicinfo)>> | Yes | Callback invoked to return the list of trusted devices.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------------------- | +| callback | AsyncCallback<Array<[DeviceBasicInfo](#devicebasicinfo)>> | Yes | Callback invoked to return the list of trusted devices.| **Error codes** @@ -203,9 +203,9 @@ Obtains all trusted devices. This API uses a promise to return the result. **Return value** - | Type | Description | - | ---------------------------------------------------------- | ---------------------------------- | - | Promise<Array<[DeviceBasicInfo](#devicebasicinfo)>> | Promise used to return the result.| +| Type | Description | +| ---------------------------------------------------------- | ---------------------------------- | +| Promise<Array<[DeviceBasicInfo](#devicebasicinfo)>> | Promise used to return the result.| **Error codes** @@ -237,9 +237,9 @@ Obtains the network ID of the local device. **Return value** - | Name | Description | - | ------------------------- | ---------------- | - | string | Network ID of the local device obtained.| +| Name | Description | +| ------------------------- | ---------------- | +| string | Network ID of the local device obtained.| **Error codes** @@ -272,9 +272,9 @@ Obtains the local device name. **Return value** - | Name | Description | - | ------------------------- | ---------------- | - | string | Name of the local device obtained.| +| Name | Description | +| ------------------------- | ---------------- | +| string | Name of the local device obtained.| **Error codes** @@ -307,9 +307,9 @@ Obtains the local device type. **Return value** - | Name | Description | - | ------------------------- | ---------------- | - | number | Local device type obtained.| +| Name | Description | +| ------------------------- | ---------------- | +| number | Local device type obtained.| **Error codes** @@ -342,9 +342,9 @@ Obtains the local device ID. **Return value** - | Name | Description | - | ------------------------- | ---------------- | - | string | Local device ID obtained.| +| Name | Description | +| ------------------------- | ---------------- | +| string | Local device ID obtained.| **Error codes** @@ -377,15 +377,15 @@ Obtains the device name based on the network ID of the specified device. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | --------- | - | networkId| string | Yes | Network ID of the device.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| networkId| string | Yes | Network ID of the device.| **Return value** - | Name | Description | - | ------------------------- | ---------------- | - | string | Device name obtained.| +| Name | Description | +| ------------------------- | ---------------- | +| string | Device name obtained.| **Error codes** @@ -420,15 +420,15 @@ Obtains the device type based on the network ID of the specified device. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | --------- | - | networkId| string | Yes | Network ID of the device.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| networkId| string | Yes | Network ID of the device.| **Return value** - | Name | Description | - | ------------------------- | ---------------- | - | number | Device type obtained.| +| Name | Description | +| ------------------------- | ---------------- | +| number | Device type obtained.| **Error codes** @@ -463,10 +463,10 @@ Starts to discover devices nearby. The discovery process automatically stops whe **Parameters** - | Name | Type | Mandatory | Description | - | ------------- | ------------------------------- | ---- | ----- | - | discoverParam | {[key: string]: Object} | Yes | Identifier of the device to discover. It specifies the type of the target to discover.
**discoverTargetType**: The default discovery target is device. The value is **1**.| - | filterOptions | {[key: string]: Object} | No | Options for filtering discovered devices. The default value is **undefined**, which means to discover offline devices. The following **key** values are carried:
**availableStatus(0-1)**: Discover trusted devices only. The value **0** indicates that the device is untrusted.
- **0**: The device is offline. The client needs to call **bindTarget** to bind the device.
- **1**: The device is online and can be connected.
**discoverDistance(0-100)**: Discover devices within a certain distance (in cm) from the local device.
**authenticationStatus(0-1)**: Discover devices based on the authentication status.
- **0**: The device is not authenticated.
- **1**: The device has been authenticated.
**authorizationType(0-2)**: Discover devices based on the authorization type.
- **0**: device authenticated by a temporarily agreed session key.
- **1**: device authenticated by a key of the same account.
- **2**: devices authenticated by a credential key of different accounts.| +| Name | Type | Mandatory | Description | +| ------------- | ------------------------------- | ---- | ----- | +| discoverParam | {[key: string]: Object} | Yes | Identifier of the device to discover. It specifies the type of the target to discover.
**discoverTargetType**: The default discovery target is device. The value is **1**.| +| filterOptions | {[key: string]: Object} | No | Options for filtering discovered devices. The default value is **undefined**, which means to discover offline devices. The following **key** values are carried:
**availableStatus(0-1)**: Discover trusted devices only. The value **0** indicates that the device is untrusted.
- **0**: The device is offline. The client needs to call **bindTarget** to bind the device.
- **1**: The device is online and can be connected.
**discoverDistance(0-100)**: Discover devices within a certain distance (in cm) from the local device.
**authenticationStatus(0-1)**: Discover devices based on the authentication status.
- **0**: The device is not authenticated.
- **1**: The device has been authenticated.
**authorizationType(0-2)**: Discover devices based on the authorization type.
- **0**: device authenticated by a temporarily agreed session key.
- **1**: device authenticated by a key of the same account.
- **2**: devices authenticated by a credential key of different accounts.| **Error codes** @@ -537,11 +537,11 @@ Binds a device. **Parameters** - | Name | Type | Mandatory | Description | - | ---------- | --------------------------------------------------- | ----- | ------------ | - | deviceId | string | Yes | Device ID. | - | bindParam | {[key: string]: Object} | Yes | Authentication parameters. You can determine the key-value pair to be passed in. By default, the following **key** values are carried:
**bindType**: binding type.
- **1**: PIN.
- **2**: QR code.
- 3: NFC.
- 4: No interaction.
**targetPkgName**: bundle name of the target to bind.
**appName**: application that attempts to bind the target.
**appOperation**: reason for the application to bind the target.
**customDescription**: detailed description of the operation. | - | callback | AsyncCallback<{deviceId: string, }> | Yes | Callback invoked to return the authentication result.| +| Name | Type | Mandatory | Description | +| ---------- | --------------------------------------------------- | ----- | ------------ | +| deviceId | string | Yes | Device ID. | +| bindParam | {[key: string]: Object} | Yes | Authentication parameters. You can determine the key-value pair to be passed in. By default, the following **key** values are carried:
**bindType**: binding type.
- **1**: PIN.
- **2**: QR code.
- 3: NFC.
- 4: No interaction.
**targetPkgName**: bundle name of the target to bind.
**appName**: application that attempts to bind the target.
**appOperation**: reason for the application to bind the target.
**customDescription**: detailed description of the operation. | +| callback | AsyncCallback<{deviceId: string, }> | Yes | Callback invoked to return the authentication result.| **Error codes** @@ -589,9 +589,9 @@ Unbinds a device. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------- | ---- | ---------- | - | deviceId | string | Yes | Device ID.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| deviceId | string | Yes | Device ID.| **Error codes** @@ -626,10 +626,10 @@ Replies to the user's UI operation. This API can be used only by the PIN HAP of **Parameters** - | Name | Type | Mandatory | Description | - | ------------- | --------------- | ---- | ------------------- | - | action | number | Yes | User operation. | - | actionResult | string | Yes | Operation result.| +| Name | Type | Mandatory | Description | +| ------------- | --------------- | ---- | ------------------- | +| action | number | Yes | User operation. | +| actionResult | string | Yes | Operation result.| **Example** @@ -664,10 +664,10 @@ Subscribes to the UI operation reply result. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------------------ | ---- | ------------------------------ | - | type | string | Yes | Event type to subscribe to. The value **replyResult** indicates the reply result of the UI operation.| - | callback | Callback<{ param: string}> | Yes | Callback invoked to return the UI status. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------ | ---- | ------------------------------ | +| type | string | Yes | Event type to subscribe to. The value **replyResult** indicates the reply result of the UI operation.| +| callback | Callback<{ param: string}> | Yes | Callback invoked to return the UI status. | **Example** @@ -698,10 +698,10 @@ Unsubscribes from the UI operation reply result. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | ------------------------------------- | ---- | ------------------------------ | - | type | string | Yes | Event type to unsubscribe from. The value **replyResult** indicates the reply result of the UI operation.| - | callback | Callback<{ param: string}> | No | Callback for the UI status.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------- | ---- | ------------------------------ | +| type | string | Yes | Event type to unsubscribe from. The value **replyResult** indicates the reply result of the UI operation.| +| callback | Callback<{ param: string}> | No | Callback for the UI status.| **Example** @@ -725,10 +725,10 @@ Subscribes to changes in the device state. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ------------------------------ | - | type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event.| - | callback | Callback<{ action: [DeviceStateChange](#devicestatechange), device: [DeviceBasicInfo](#devicebasicinfo) }> | Yes | Callback invoked to return the device information and state. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------------ | +| type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event.| +| callback | Callback<{ action: [DeviceStateChange](#devicestatechange), device: [DeviceBasicInfo](#devicebasicinfo) }> | Yes | Callback invoked to return the device information and state. | **Example** @@ -754,10 +754,10 @@ Unsubscribes from changes in the device state. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | --------------------------- | - | type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event. | - | callback | Callback<{ action: [deviceStateChange](#devicestatechange), device: [DeviceBasicInfo](#devicebasicinfo) }> | No | Callback for the device information and state.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------------------------- | +| type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event. | +| callback | Callback<{ action: [deviceStateChange](#devicestatechange), device: [DeviceBasicInfo](#devicebasicinfo) }> | No | Callback for the device information and state.| **Example** @@ -783,10 +783,10 @@ Subscribes to device discovery events. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | -------------------------- | - | type | string | Yes | Event type. The value **'discoverSuccess'** indicates an event of successful device discovery.| - | callback | Callback<{ device: [DeviceBasicInfo](#devicebasicinfo) }> | Yes | Callback invoked to return a device discovery event. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | -------------------------- | +| type | string | Yes | Event type. The value **'discoverSuccess'** indicates an event of successful device discovery.| +| callback | Callback<{ device: [DeviceBasicInfo](#devicebasicinfo) }> | Yes | Callback invoked to return a device discovery event. | **Example** @@ -812,10 +812,10 @@ Unsubscribes from device discovery events. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | --------------------------- | - | type | string | Yes | Event type. The value **'discoverSuccess'** indicates a device discovery event. | - | callback | Callback<{ device: [DeviceBasicInfo](#devicebasicinfo) }> | No | Callback for the device discovery event.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------------------------- | +| type | string | Yes | Event type. The value **'discoverSuccess'** indicates a device discovery event. | +| callback | Callback<{ device: [DeviceBasicInfo](#devicebasicinfo) }> | No | Callback for the device discovery event.| **Example** @@ -841,10 +841,10 @@ Subscribes to device name changes. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ------------------------------ | - | type | string | Yes | Event type. The value **'deviceNameChange'** indicates a device name change event.| - | callback | Callback<{ deviceName: string}> | Yes | Callback invoked to return the device name change. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------------ | +| type | string | Yes | Event type. The value **'deviceNameChange'** indicates a device name change event.| +| callback | Callback<{ deviceName: string}> | Yes | Callback invoked to return the device name change. | **Example** @@ -870,10 +870,10 @@ Unsubscribes from device name changes. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ------------------------------ | - | type | string | Yes | Event type. The value **'deviceNameChange'** indicates a device name change event.| - | callback | Callback<{ deviceName: string}> | No | Callback for the device name change. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------------ | +| type | string | Yes | Event type. The value **'deviceNameChange'** indicates a device name change event.| +| callback | Callback<{ deviceName: string}> | No | Callback for the device name change. | **Example** @@ -899,10 +899,10 @@ Subscribes to device discovery failures. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ------------------------------ | - | type | string | Yes | Event type. The value **'discoverFailure'** indicates an event reported when device discovery fails.| - | callback | Callback<{ reason: number }> | Yes | Callback invoked to return a device discovery failure. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------------ | +| type | string | Yes | Event type. The value **'discoverFailure'** indicates an event reported when device discovery fails.| +| callback | Callback<{ reason: number }> | Yes | Callback invoked to return a device discovery failure. | **Example** @@ -928,10 +928,10 @@ Unsubscribes from device discovery failures. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ----------------- | - | type | string | Yes | Event type. The value **'discoverFailure'** indicates an event reported when device discovery fails. | - | callback | Callback<{ reason: number }> | No | Callback for the device discovery failure.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ----------------- | +| type | string | Yes | Event type. The value **'discoverFailure'** indicates an event reported when device discovery fails. | +| callback | Callback<{ reason: number }> | No | Callback for the device discovery failure.| **Example** @@ -957,10 +957,10 @@ Subscribes to dead events of the **DeviceManager** service. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ----------------------- | ---- | ---------------------------------------- | - | type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| - | callback | Callback<{}> | No | Callback invoked when a dead event of the **DeviceManager** service occurs. | +| Name | Type | Mandatory | Description | +| -------- | ----------------------- | ---- | ---------------------------------------- | +| type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| +| callback | Callback<{}> | No | Callback invoked when a dead event of the **DeviceManager** service occurs. | **Example** @@ -986,10 +986,10 @@ Unsubscribes from dead events of the **DeviceManager** service. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ----------------------- | ---- | ---------------------------------------- | - | type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| - | callback | Callback<{}> | No | Callback for the dead event of the **DeviceManager** service. | +| Name | Type | Mandatory | Description | +| -------- | ----------------------- | ---- | ---------------------------------------- | +| type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| +| callback | Callback<{}> | No | Callback for the dead event of the **DeviceManager** service. | **Example** @@ -1002,4 +1002,4 @@ Unsubscribes from dead events of the **DeviceManager** service. console.error("serviceDie errCode:" + err.code + ",errMessage:" + err.message); } ``` - + diff --git a/en/application-dev/reference/apis/js-apis-file-fs.md b/en/application-dev/reference/apis/js-apis-file-fs.md index 5effa68ff4..3e783a1858 100644 --- a/en/application-dev/reference/apis/js-apis-file-fs.md +++ b/en/application-dev/reference/apis/js-apis-file-fs.md @@ -2687,7 +2687,7 @@ Represents detailed file information. Before calling any API of the **Stat()** c | Name | Type | Readable | Writable | Description | | ------ | ------ | ---- | ---- | ---------------------------------------- | | ino | number | Yes | No | File ID. Different files on the same device have different **ino**s.| | -| mode | number | Yes | No | File permissions. The meaning of each bit is as follows:
- **0o400**: The owner has the read permission on a regular file or a directory entry.
- **0o200**: The owner has the permission to write a regular file or create and delete a directory entry.
- **0o100**: The owner has the permission to execute a regular file or search for the specified path in a directory.
- **0o040**: The user group has the read permission on a regular file or a directory entry.
- **0o020**: The user group has the permission to write a regular file or create and delete a directory entry.
- **0o010**: The user group has the permission to execute a regular file or search for the specified path in a directory.
- **0o004**: Other users have the permission to read a regular file or read a directory entry.
- **0o002**: Other users have the permission to write a regular file or create and delete a directory entry.
- **0o001**: Other users have the permission to execute a regular file or search for the specified path in a directory.| +| mode | number | Yes | No | File permissions. The meaning of each bit is as follows:
**NOTE**
The following values are in octal format. The returned values are in decimal format. You need to convert the values.
- **0o400**: The owner has the permission to read a regular file or a directory entry.
- **0o200**: The owner has the permission to write a regular file or create and delete a directory entry.
- **0o100**: The owner has the permission to execute a regular file or search for the specified path in a directory.
- **0o040**: The user group has the permission to read a regular file or a directory entry.
- **0o020**: The user group has the permission to write a regular file or create and delete a directory entry.
- **0o010**: The user group has the permission to execute a regular file or search for the specified path in a directory.
- **0o004**: Other users have the permission to read a regular file or a directory entry.
- **0o002**: Other users have the permission to write a regular file or create and delete a directory entry.
- **0o001**: Other users have the permission to execute a regular file or search for the specified path in a directory.| | uid | number | Yes | No | ID of the file owner.| | gid | number | Yes | No | ID of the user group of the file.| | size | number | Yes | No | File size, in bytes. This parameter is valid only for regular files. | diff --git a/en/application-dev/reference/apis/js-apis-fileAccess.md b/en/application-dev/reference/apis/js-apis-fileAccess.md index 09dfaa4828..c54f46c1db 100644 --- a/en/application-dev/reference/apis/js-apis-fileAccess.md +++ b/en/application-dev/reference/apis/js-apis-fileAccess.md @@ -1,6 +1,6 @@ # @ohos.file.fileAccess (User File Access and Management) -The **fileAccess** module provides a framework for accessing and operating user files based on the ExtensionAbility mechanism. This module interacts with file management services, such as the media library and external storage management service, and provides a set of unified interfaces for system applications to access and manage files. The media library service allows access to user files on local and distributed devices. The external storage management service allows access to the user files stored on devices, such as shared disks, USB flash drives, and SD cards. +The **fileAccess** module provides a framework for accessing and operating user files based on the ExtensionAbility mechanism. This module interacts with a variety of file management services, such as the storage management service, and provides a set of unified file access and management interfaces for system applications. The storage management service manages both the directories of the built-in storage and resources on external devices, such as shared disks, USB flash drives, and SD cards. >**NOTE** > @@ -124,10 +124,9 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e createFileAccessHelper() { let fileAccessHelper = null; // Obtain wantInfos by using getFileAccessAbilityInfo(). - // Create a helper object to interact with the media library service only. let wantInfos = [ { - "bundleName": "com.ohos.medialibrary.medialibrarydata", + "bundleName": "com.ohos.UserFile.ExternalFileManager", "abilityName": "FileExtensionAbility", }, ] @@ -248,7 +247,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e try { let fileIterator = fileInfoDir.listFile(); // listFile() with the filter implementation. - // let fileIterator = rootInfo.listFile(filter); + // let fileIterator = fileInfoDir.listFile(filter); if (!fileIterator) { console.error("listFile interface returns an undefined object"); return; @@ -304,7 +303,7 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e try { let fileIterator = fileInfoDir.scanFile(); // scanFile() with the filter implementation. - // let fileIterator = rootInfo.scanFile(filter); + // let fileIterator = fileInfoDir.scanFile(filter); if (!fileIterator) { console.error("scanFile interface returns an undefined object"); return; @@ -651,10 +650,10 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, sourceUri indicates the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let sourceUri = "file://media/file/6"; + let sourceUri = "file://docs/storage/Users/currentUser/Download"; let displayName = "file1" let fileUri = null; try { @@ -695,10 +694,10 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, sourceUri indicates the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let sourceUri = "file://media/file/6"; + let sourceUri = "file://docs/storage/Users/currentUser/Download"; let displayName = "file1" try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. @@ -744,10 +743,10 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, sourceUri indicates the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let sourceUri = "file://media/file/6"; + let sourceUri = "file://docs/storage/Users/currentUser/Download"; let dirName = "dirTest" let dirUri = null; try { @@ -788,10 +787,10 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, sourceUri indicates the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let sourceUri = "file://media/file/6"; + let sourceUri = "file://docs/storage/Users/currentUser/Download"; let dirName = "dirTest" try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. @@ -837,10 +836,10 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, targetUri indicates a file in the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let targetUri = "file://media/file/100"; + let targetUri = "file://docs/storage/Users/currentUser/Download/1.txt"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. let fd = await fileAccessHelper.openFile(targetUri, fileAccess.OPENFLAGS.READ); @@ -874,10 +873,10 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, targetUri indicates a file in the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let targetUri = "file://media/file/100"; + let targetUri = "file://docs/storage/Users/currentUser/Download/1.txt"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. fileAccessHelper.openFile(targetUri, fileAccess.OPENFLAGS.READ, function (err, fd) { @@ -921,10 +920,10 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, targetUri indicates a file in the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let targetUri = "file://media/file/100"; + let targetUri = "file://docs/storage/Users/currentUser/Download/1.txt"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. let code = await fileAccessHelper.delete(targetUri); @@ -959,10 +958,10 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, targetUri indicates a file in the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let targetUri = "file://media/file/100"; + let targetUri = "file://docs/storage/Users/currentUser/Download/1.txt"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. fileAccessHelper.delete(targetUri, function (err, code) { @@ -1007,11 +1006,11 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. - // In the sample code, sourceFile destFile indicates the file or directory in the Download directory. The URI is the URI in fileInfo. + // A built-in storage directory is used as an example. + // In the sample code, sourceFile and destFile indicate the files or directories in the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let sourceFile = "file://media/file/102"; - let destFile = "file://media/file/101"; + let sourceFile = "file://docs/storage/Users/currentUser/Download/1.txt"; + let destFile = "file://docs/storage/Users/currentUser/Download/test"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. let fileUri = await fileAccessHelper.move(sourceFile, destFile); @@ -1046,11 +1045,11 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. - // In the sample code, sourceFile destFile indicates the file or directory in the Download directory. The URI is the URI in fileInfo. + // A built-in storage directory is used as an example. + // In the sample code, sourceFile and destFile indicate the files or directories in the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let sourceFile = "file://media/file/102"; - let destFile = "file://media/file/101"; + let sourceFile = "file://docs/storage/Users/currentUser/Download/1.txt"; + let destFile = "file://docs/storage/Users/currentUser/Download/test"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. fileAccessHelper.move(sourceFile, destFile, function (err, fileUri) { @@ -1095,10 +1094,10 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, sourceDir indicates a file in the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let sourceDir = "file://media/file/100"; + let sourceDir = "file://docs/storage/Users/currentUser/Download/1.txt"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. let DestDir = await fileAccessHelper.rename(sourceDir, "testDir"); @@ -1133,10 +1132,10 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, sourceDir indicates a file in the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let sourceDir = "file://media/file/100"; + let sourceDir = "file://docs/storage/Users/currentUser/Download/1.txt"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. fileAccessHelper.rename(sourceDir, "testDir", function (err, DestDir) { @@ -1180,10 +1179,10 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, sourceDir indicates a file in the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let sourceDir = "file://media/file/100"; + let sourceDir = "file://docs/storage/Users/currentUser/Download/1.txt"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. let existJudgment = await fileAccessHelper.access(sourceDir); @@ -1220,10 +1219,10 @@ For details about error codes, see [File Management Error Codes](../errorcodes/e **Example** ```js - // The media library URI is used as an example. - // In the sample code, sourceDir indicates a file in the Download directory. The URI is the URI in fileInfo. + // A built-in storage directory is used as an example. + // In the sample code, sourceDir indicates a folder in the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let sourceDir = "file://media/file/100"; + let sourceDir = "file://docs/storage/Users/currentUser/Download/test"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. fileAccessHelper.access(sourceDir, function (err, existJudgment) { @@ -1266,10 +1265,10 @@ Obtains a **FileInfo** object based on the specified URI. This API uses a promis **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, sourceUri indicates the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let sourceUri = "file://media/file/6"; + let sourceUri = "file://docs/storage/Users/currentUser/Download"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. let fileInfo = await fileAccessHelper.getFileInfoFromUri(sourceUri); @@ -1298,10 +1297,10 @@ Obtains a **FileInfo** object based on the specified URI. This API uses an async **Example** ```js - // The media library URI is used as an example. + // A built-in storage directory is used as an example. // In the sample code, sourceUri indicates the Download directory. The URI is the URI in fileInfo. // You can use the URI obtained. - let sourceUri = "file://media/file/6"; + let sourceUri = "file://docs/storage/Users/currentUser/Download"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. fileAccessHelper.getFileInfoFromUri(sourceUri, function (err, fileInfo) { @@ -1342,7 +1341,6 @@ Obtains a **FileInfo** object based on the **relativePath**. This API uses a pro **Example** ```js - // The relative path of the Media Library is used as an example. // In the sample code, relativePath indicates the Download directory, which is the relativePath in fileInfo. // You can use the relativePath obtained. let relativePath = "Download/"; @@ -1374,7 +1372,6 @@ Obtains a **FileInfo** object based on the **relativePath**. This API uses an as **Example** ```js - // The relative path of the Media Library is used as an example. // In the sample code, relativePath indicates the Download directory, which is the relativePath in fileInfo. // You can use the relativePath obtained. let relativePath = "Download/"; @@ -1392,90 +1389,6 @@ Obtains a **FileInfo** object based on the **relativePath**. This API uses an as }; ``` -### getThumbnail10+ - -getThumbnail(uri: string, size: image.Size) : Promise<image.PixelMap> - -Obtains the **Pixelmap** object of a media file based on the specified URI and size. This API uses a promise to return the result. - -**System capability**: SystemCapability.FileManagement.UserFileService - -**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ----------------------------------- | ---- | ----------- | -| uri | string | Yes | URI of the media file.| -| size | [image.Size](js-apis-image.md#size) | Yes | Size of the thumbnail. | - -**Return value** - -| Type | Description | -| :---------------------------- | :----------------- | -| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise used to return the **Pixelmap** object obtained.| - -**Example** - -```js -// The media library URI is used as an example. -// In the sample code, targetUri indicates a media file (image, audio, or video) in the Download directory. The URI is the URI in fileInfo. -// You can use the URI obtained. -let targetUri = "file://media/image/100"; -let size = { width: 128, height: 128 }; -try { - // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. - let pixelMap = await fileAccessHelper.getThumbnail(targetUri, size); - let imageInfo = await pixelMap.getImageInfo(); - console.log("getThumbnail sucess, pixelMap.width: " + imageInfo.size.width); - console.log("getThumbnail sucess, pixelMap.height: " + imageInfo.size.height); -} catch (error) { - console.error("getThumbnail failed, errCode:" + error.code + ", errMessage:" + error.message); -}; -``` - -### getThumbnail10+ - - getThumbnail(uri: string, size: image.Size, callback: AsyncCallback<image.PixelMap>) : void - -Obtains the **Pixelmap** object of a media file based on the specified URI and size. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.FileManagement.UserFileService - -**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------- | ---- | ------------------ | -| uri | string | Yes | URI of the media file. | -| size | [image.Size](js-apis-image.md#size) | Yes | Size of the thumbnail. | -| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | Yes | Callback invoked to return the **Pixelmap** object obtained.| - -**Example** - -```js -// The media library URI is used as an example. -// In the sample code, targetUri indicates a media file (image, audio, or video) in the Download directory. The URI is the URI in fileInfo. -// You can use the URI obtained. -let targetUri = "file://media/image/100"; -let size = { width: 128, height: 128 }; -try { - // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. - fileAccessHelper.getThumbnail(targetUri, size, async(err, pixelMap) => { - if (err) { - console.error("Failed to getThumbnail in async, errCode:" + err.code + ", errMessage:" + err.message); - return; - } - let imageInfo = await pixelMap.getImageInfo(); - console.log("getThumbnail sucess, pixelMap.width: " + imageInfo.size.width); - console.log("getThumbnail sucess, pixelMap.height: " + imageInfo.size.height); - }); -} catch (error) { - console.error("getThumbnail failed, errCode:" + error.code + ", errMessage:" + error.message); -}; -``` - ### query10+ query(uri:string, metaJson: string) : Promise<string> @@ -1502,7 +1415,7 @@ Queries the attribute information about a file or directory based on the URI. Th **Example** ```js -var imageFileRelativePath = "Download/queryTest/image/01.jpg"; +var imageFileRelativePath = "/storage/Users/currentUser/Download/queryTest/image/01.jpg"; var jsonStrSingleRelativepath = JSON.stringify({ [fileAccess.FileKey.RELATIVE_PATH]: "" }); try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. @@ -1535,7 +1448,7 @@ Queries the attribute information about a file or directory based on the URI. Th **Example** ```js -var imageFileRelativePath = "Download/queryTest/image/01.jpg"; +var imageFileRelativePath = "/storage/Users/currentUser/Download/queryTest/image/01.jpg"; var jsonStrSingleRelativepath = JSON.stringify({ [fileAccess.FileKey.RELATIVE_PATH]: "" }); try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. @@ -1566,8 +1479,8 @@ Copies a file or directory. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | --------- | ------- | ---- | ------------------------------------------------------------ | -| sourceUri | string | Yes | URI of the file or directory to copy, for example, **file://media/file/102**. | -| destUri | string | Yes | URI of the destination directory, for example, **file://media/file/101**. | +| sourceUri | string | Yes | URI of the file or folder to copy, for example, **file://docs/storage/Users/currentUser/Download/1.txt**. | +| destUri | string | Yes | URI of the file or folder created, for example, **file://docs/storage/Users/currentUser/Download/test**. | | force | boolean | No | Whether to forcibly overwrite the file with the same name.
If **force** is **true**, the file with the same name will be overwritten. If **force** is **false** or not specified, the file with the same name will not be overwritten.| **Return value** @@ -1579,11 +1492,11 @@ Copies a file or directory. This API uses a promise to return the result. Example 1: Copy a file with **force** unspecified. ```js -// The media library URI is used as an example. +// A built-in storage directory is used as an example. // In the sample code, sourceFile indicates the file (directory) in the Download directory to copy, destFile indicates the destination directory in the Download directory, and uri is to URI in fileInfo. // You can use the URI obtained. -let sourceFile = "file://media/file/102"; -let destFile = "file://media/file/101"; +let sourceFile = "file://docs/storage/Users/currentUser/Download/1.txt"; +let destFile = "file://docs/storage/Users/currentUser/Download/test"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. let copyResult = await fileAccessHelper.copy(sourceFile, destFile); @@ -1605,11 +1518,11 @@ try { Example 2: Copy a file or directory when **force** set to **true**. ```js -// The media library URI is used as an example. +// A built-in storage directory is used as an example. // In the sample code, sourceFile indicates the file (directory) in the Download directory to copy, destFile indicates the destination directory in the Download directory, and uri is to URI in fileInfo. // You can use the URI obtained. -let sourceFile = "file://media/file/102"; -let destFile = "file://media/file/101"; +let sourceFile = "file://docs/storage/Users/currentUser/Download/1.txt"; +let destFile = "file://docs/storage/Users/currentUser/Download/test"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. let copyResult = await fileAccessHelper.copy(sourceFile, destFile, true); @@ -1642,18 +1555,18 @@ Copies a file or directory. This API uses an asynchronous callback to return the | Name | Type | Mandatory| Description | | --------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ | -| sourceUri | string | Yes | URI of the file or directory to copy, for example, **file://media/file/102**. | -| destUri | string | Yes | URI of the destination directory, for example, **file://media/file/101**. | +| sourceUri | string | Yes | URI of the file or folder to copy, for example, **file://docs/storage/Users/currentUser/Download/1.txt**. | +| destUri | string | Yes | URI of the file or folder created, for example, **file://docs/storage/Users/currentUser/Download/test**. | | callback | AsyncCallback<Array<[CopyResult](#copyresult10)>> | Yes | Callback invoked to return the result. If the file or directory is copied successfully, no information is returned. If the file copy fails, **copyResult** is returned.| **Example** ```js -// The media library URI is used as an example. +// A built-in storage directory is used as an example. // In the sample code, sourceFile indicates the file (directory) in the Download directory to copy, destFile indicates the destination directory in the Download directory, and uri is to URI in fileInfo. // You can use the URI obtained. -let sourceFile = "file://media/file/102"; -let destFile = "file://media/file/101"; +let sourceFile = "file://docs/storage/Users/currentUser/Download/1.txt"; +let destFile = "file://docs/storage/Users/currentUser/Download/test"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. fileAccessHelper.copy(sourceFile, destFile, async (err, copyResult) => { @@ -1691,19 +1604,19 @@ Copies a file or directory. This API uses an asynchronous callback to return the | Name | Type | Mandatory| Description | | --------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ | -| sourceUri | string | Yes | URI of the file or directory to copy, for example, **file://media/file/102**. | -| destUri | string | Yes | URI of the destination directory, for example, **file://media/file/101**. | +| sourceUri | string | Yes | URI of the file or folder to copy, for example, **file://docs/storage/Users/currentUser/Download/1.txt**. | +| destUri | string | Yes | URI of the file or folder created, for example, **file://docs/storage/Users/currentUser/Download/test**. | | force | boolean | Yes | Whether to forcibly overwrite the file with the same name.
If **force** is **true**, the file with the same name will be overwritten. If **force** is **false** or not specified, the file with the same name will not be overwritten.| | callback | AsyncCallback<Array<[CopyResult](#copyresult10)>> | Yes | Callback invoked to return the result. If the file or directory is copied successfully, no information is returned. If the file copy fails, **copyResult** is returned.| **Example** ```js -// The media library URI is used as an example. +// A built-in storage directory is used as an example. // In the sample code, sourceFile indicates the file (directory) in the Download directory to copy, destFile indicates the destination directory in the Download directory, and uri is to URI in fileInfo. // You can use the URI obtained. -let sourceFile = "file://media/file/102"; -let destFile = "file://media/file/101"; +let sourceFile = "file://docs/storage/Users/currentUser/Download/1.txt"; +let destFile = "file://docs/storage/Users/currentUser/Download/test"; try { // Obtain fileAccessHelper by referring to the sample code of fileAccess.createFileAccessHelper. fileAccessHelper.copy(sourceFile, destFile, true, async (err, copyResult) => { @@ -1771,6 +1684,3 @@ Enumerates the keys of the file attributes to query. | DATE_MODIFIED | 'date_modified' | Date when a file was modified, for example, **1665310670**. | | RELATIVE_PATH | 'relative_path' | Relative path of the file, for example, **Pictures/Screenshots/**.| | FILE_SIZE | 'size' | Size of a file, in bytes. | -| WIDTH | 'width' | Width of the image file, in pixels. | -| HEIGHT | 'height' | Height of the image file, in pixels. | -| DURATION | 'duration' | Duration of the audio or video file, in milliseconds. | diff --git a/en/application-dev/reference/apis/js-apis-nfcTag.md b/en/application-dev/reference/apis/js-apis-nfcTag.md index 9aeadd303e..07e68bebed 100644 --- a/en/application-dev/reference/apis/js-apis-nfcTag.md +++ b/en/application-dev/reference/apis/js-apis-nfcTag.md @@ -23,20 +23,18 @@ Before developing applications related to tag read and write, you must declare N // Add the nfc tag action. "ohos.nfc.tag.action.TAG_FOUND" + ], + "uris": [ + { + "type":"tag-tech/NfcA" + }, + { + "type":"tag-tech/IsoDep" + } + // Add other technology if neccessary, + // such as NfcB, NfcF, NfcV, Ndef, MifareClassic, MifareUL, and NdefFormatable. ] } - ], - "metadata": [ - { - "name": "tag-tech", - "value": "NfcA" - }, - { - "name": "tag-tech", - "value": "IsoDep" - } - // Add other technologies, - // such as NfcB, NfcF, NfcV, Ndef, MifareClassic, MifareUL, and NdefFormatable. ] } ], @@ -49,13 +47,11 @@ Before developing applications related to tag read and write, you must declare N } } ``` -> **CAUTION**
+> **CAUTION** > > - The **actions** field is mandatory. It must be **ohos.nfc.tag.action.TAG_FOUND** and cannot be changed. -> - The **name** field under **metadata** is mandatory. It must be **tag-tech** and cannot be changed. -> - The **value** field under **metadata** is mandatory. It can be **NfcA**, **NfcB**, **NfcF**, **NfcV**, **IsoDep**, **Ndef**, **MifareClassic**, **MifareUL**, **NdefFormatable** or any of their combinations. Incorrect settings of this field will cause a parsing failure. +> - The **type** field under **uris** must start with **tag-tech/**, followed by NfcA, NfcB, NfcF, NfcV, IsoDep, Ndef, MifareClassic, MifareUL, or NdefFormatable. If there are multiple types, enter them in different lines. Incorrect settings of this field will cause a parsing failure. > - The **name** field under **requestPermissions** is mandatory. It must be **ohos.permission.NFC_TAG** and cannot be changed. - ## **Modules to Import** ```js @@ -528,8 +524,16 @@ import tag from '@ohos.nfc.tag'; let elementName = null; let discTech = [tag.NFC_A, tag.NFC_B]; // replace with the tech(s) that is needed by foreground ability -function foregroundCb(tagInfo: any) { - console.log("foreground callback: tag found tagInfo = ", JSON.stringify(tagInfo)); + +function foregroundCb(err, taginfo) { + if (!err) { + console.log("foreground callback: tag found tagInfo = ", JSON.stringify(tagInfo)); + } else { + console.log("foreground callback err: " + err.message); + return; + } + // other Operations of taginfo + } export default class MainAbility extends UIAbility { @@ -885,7 +889,7 @@ Enumerates the tag technology types. | **Name** | **Value**| **Description** | | ---------------------------- | ------ | --------------------------- | | NFC_A | 1 | NFC-A (ISO 14443-3A). | -| NFC_B | 2 | NFC-B (ISO 14443-3B).| +| NFC_B | 2 | NFC-B (ISO 14443-3B). | | ISO_DEP | 3 | ISO-DEP (ISO 14443-4).| | NFC_F | 4 | NFC-F (JIS 6319-4). | | NFC_V | 5 | NFC-V (ISO 15693). | diff --git a/en/application-dev/reference/apis/js-apis-photoAccessHelper.md b/en/application-dev/reference/apis/js-apis-photoAccessHelper.md index 808334727b..aae05347c5 100644 --- a/en/application-dev/reference/apis/js-apis-photoAccessHelper.md +++ b/en/application-dev/reference/apis/js-apis-photoAccessHelper.md @@ -1275,6 +1275,151 @@ async function example() { } ``` +### getPhotoIndex + +getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions, callback: AsyncCallback<number>): void + +Obtains the index of an image or video in an album. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_IMAGEVIDEO + +**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| photoUri | string | Yes | URI of the media asset whose index is to be obtained.| +| albumUri | string | Yes | Album URI, which can be an empty string. If it is an empty string, all the media assets in the Gallery are obtained by default. | +| options | [FetchOptions](#fetchoptions) | Yes | Fetch options. Only one search condition or sorting mode must be set in **predicates**. If no value is set or multiple search conditions or sorting modes are set, the API cannot be called successfully. | + +**Return value** + +| Type | Description | +| --------------------------------------- | ----------------- | +| AsyncCallback<number>| Promise used to return the index obtained.| + +**Error codes** + +For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md). + +| ID| Error Message| +| -------- | ---------------------------------------- | +| 401 | if parameter is invalid. | + +**Example** + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +async function example() { + console.info('getPhotoIndexDemo'); + let predicatesForGetAsset = new dataSharePredicates.DataSharePredicates(); + let fetchOp = { + fetchColumns: [], + predicates: predicatesForGetAsset + }; + //Obtain the uri of the album + let albumFetchResult = await helper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.FAVORITE, fetchOp); + let album = await albumFetchResult.getFirstObject(); + + let predicates = new dataSharePredicates.DataSharePredicates(); + predicates.orderByAsc("add_modified"); + let fetchOptions = { + fetchColumns: [], + predicates: predicates + }; + let photoFetchResult = await album.getAssets(fetchOptions); + let expectIndex = 1; + //Obtain the uri of the second file + let photoAsset = await photoFetchResult.getObjectByPosition(expectIndex); + + photoAccessHelper.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions, (err, index) => { + try { + if (err == undefined) { + console.info(`getPhotoIndex successfully and index is : ${index}`); + } else { + console.info(`getPhotoIndex failed;`); + } + } catch (error) { + console.info(`getPhotoIndex failed; error: ${error}`); + } + } +} +``` + +### getPhotoIndex + +getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions): Promise<number> + +Obtains the index of an image or video in an album. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_IMAGEVIDEO + +**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| photoUri | string | Yes | URI of the media asset whose index is to be obtained.| +| albumUri | string | Yes | Album URI, which can be an empty string. If it is an empty string, all the media assets in the Gallery are obtained by default. | +| options | [FetchOptions](#fetchoptions) | Yes | Fetch options. Only one search condition or sorting mode must be set in **predicates**. If no value is set or multiple search conditions or sorting modes are set, the API cannot be called successfully. | + +**Return value** + +| Type | Description | +| --------------------------------------- | ----------------- | +| Promise<number>| Promise used to return the index obtained.| + +**Error codes** + +For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md). + +| ID| Error Message| +| -------- | ---------------------------------------- | +| 401 | if parameter is invalid. | + +**Example** + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +async function example() { + console.info('getPhotoIndexDemo'); + let predicatesForGetAsset = new dataSharePredicates.DataSharePredicates(); + let fetchOp = { + fetchColumns: [], + predicates: predicatesForGetAsset + }; + //Obtain the uri of the album + let albumFetchResult = await helper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.FAVORITE, fetchOp); + let album = await albumFetchResult.getFirstObject(); + + let predicates = new dataSharePredicates.DataSharePredicates(); + predicates.orderByAsc("add_modified"); + let fetchOptions = { + fetchColumns: [], + predicates: predicates + }; + let photoFetchResult = await album.getAssets(fetchOptions); + let expectIndex = 1; + //Obtain the uri of the second file + let photoAsset = await photoFetchResult.getObjectByPosition(expectIndex); + + photoAccessHelper.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions) + .then((index) => { + console.info(`getPhotoIndex successfully and index is : ${index}`); + }).catch((err) => { + console.info(`getPhotoIndex failed; error: ${err}`); + }) +} +``` + ### release release(callback: AsyncCallback<void>): void @@ -1360,7 +1505,7 @@ Provides APIs for encapsulating file asset attributes. | Name | Type | Readable| Writable| Description | | ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ | -| uri | string | Yes | No | File asset URI, for example, **file://media/image/2**. | +| uri | string | Yes | No | File asset URI, for example, **file://media/Photo/1/IMG_datetime_0001/displayName.jpg**. | | photoType | [PhotoType](#phototype) | Yes | No | Type of the file. | | displayName | string | Yes | No | File name, including the file name extension, to display. | @@ -2243,6 +2388,282 @@ async function example() { } ``` +### getExif10+ + +getExif(): Promise<string> + +Obtains a JSON string consisting of the EXIF tags of this JPG image. This API uses a promise to return the result. + +**CAUTION**
This API returns a JSON string consisting of EXIF tags. The complete EXIF information consists of **all_exif** and **js-apis-photoAccessHelper.md**. These two fields must be passed in via **fetchColumns**. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_IMAGEVIDEO + +**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**Return value** + +| Type | Description | +| --------------------------------------- | ----------------- | +| Promise<string> | Callback invoked to return the JSON string obtained.| + +**Supported EXIF tags** + +For details about the EXIF tags, see [image.PropertyKey](js-apis-image.md#propertykey7). + +| Key Value | Description | +| --------------------------------------- | ----------------- | +| BitsPerSample | Number of bits per pixel.| +| Orientation | Image orientation.| +| ImageLength | Image length.| +| ImageWidth | Image width.| +| GPSLatitude | GPS latitude of the image.| +| GPSLongitude | GPS longitude of the image.| +| GPSLatitudeRef | Longitude reference, for example, W or E.| +| GPSLongitudeRef | Latitude reference, for example, N or S.| +| DateTimeOriginal | Shooting time.| +| ExposureTime | Exposure time.| +| SceneType | Shooting scene type.| +| ISOSpeedRatings | ISO sensitivity or speed.| +| FNumber | f-number.| +| DateTime | Date and time when the image was last modified.| +| GPSTimeStamp | GPS timestamp.| +| GPSDateStamp | GPS date stamp.| +| ImageDescription | Image description.| +| Make | Camera vendor.| +| Model | Model.| +| PhotoMode | Photo mode.| +| SensitivityType | Sensitivity type.| +| StandardOutputSensitivity | Standard output sensitivity.| +| RecommendedExposureIndex | Recommended exposure index.| +| ApertureValue | Aperture value.| +| MeteringMode | Metering mode.| +| LightSource | Light source.| +| Flash | Flash status.| +| FocalLength | Focal length.| +| UserComment | User comment.| +| PixelXDimension | Pixel X dimension.| +| PixelYDimension | Pixel Y dimension.| +| WhiteBalance | White balance.| +| FocalLengthIn35mmFilm | Focal length in 35 mm film.| +| ExposureBiasValue | Exposure compensation.| + +**Example** + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +async function example() { + try { + console.info('getExifDemo'); + let predicates = new dataSharePredicates.DataSharePredicates(); + let fetchOptions = { + fetchColumns: [ 'all_exif', photoKeys.USER_COMMENT], + predicates: predicates + }; + let fetchResult = await phAccessHelper.getAssets(fetchOptions); + let fileAsset = await fetchResult.getFirstObject(); + let exifMessage = await fileAsset.getExif(); + let userCommentKey = 'UserComment'; + let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]); + fetchResult.close(); + } catch (err) { + console.error('getExifDemoCallback failed with error: ' + err); + } +} +``` + +### getExif10+ + +getExif(callback: AsyncCallback<string>): void + +Obtains a JSON string consisting of the EXIF tags of this JPG image. This API uses an asynchronous callback to return the result. + +**CAUTION**
This API returns a JSON string consisting of EXIF tags. The complete EXIF information consists of **all_exif** and **ImageVideoKey.USER_COMMENT**. These two fields must be passed in via **fetchColumns**. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_IMAGEVIDEO + +**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<string> | Yes | Callback invoked to return the JSON string obtained.| + +**Supported EXIF tags** + +For details about the EXIF tags, see [image.PropertyKey](js-apis-image.md#propertykey7). + +| Key Value | Description | +| --------------------------------------- | ----------------- | +| BitsPerSample | Number of bits per pixel.| +| Orientation | Image orientation.| +| ImageLength | Image length.| +| ImageWidth | Image width.| +| GPSLatitude | GPS latitude of the image.| +| GPSLongitude | GPS longitude of the image.| +| GPSLatitudeRef | Longitude reference, for example, W or E.| +| GPSLongitudeRef | Latitude reference, for example, N or S.| +| DateTimeOriginal | Shooting time.| +| ExposureTime | Exposure time.| +| SceneType | Shooting scene type.| +| ISOSpeedRatings | ISO sensitivity or speed.| +| FNumber | f-number.| +| DateTime | Date and time when the image was last modified.| +| GPSTimeStamp | GPS timestamp.| +| GPSDateStamp | GPS date stamp.| +| ImageDescription | Image description.| +| Make | Camera vendor.| +| Model | Model.| +| PhotoMode | Photo mode.| +| SensitivityType | Sensitivity type.| +| StandardOutputSensitivity | Standard output sensitivity.| +| RecommendedExposureIndex | Recommended exposure index.| +| ApertureValue | Aperture value.| +| MeteringMode | Metering mode.| +| LightSource | Light source.| +| Flash | Flash status.| +| FocalLength | Focal length.| +| UserComment | User comment.| +| PixelXDimension | Pixel X dimension.| +| PixelYDimension | Pixel Y dimension.| +| WhiteBalance | White balance.| +| FocalLengthIn35mmFilm | Focal length in 35 mm film.| +| ExposureBiasValue | Exposure compensation.| + +**Example** + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +async function example() { + try { + console.info('getExifDemo'); + let predicates = new dataSharePredicates.DataSharePredicates(); + let fetchOptions = { + fetchColumns: [ 'all_exif', photoKeys.USER_COMMENT], + predicates: predicates + }; + let fetchResult = await phAccessHelper.getAssets(fetchOptions); + let fileAsset = await fetchResult.getFirstObject(); + let userCommentKey = 'UserComment'; + fileAsset.getExif((err, exifMessage) => { + if (exifMessage != undefined) { + let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]); + } else { + console.error('getExif failed, message = ', err); + } + }); + fetchResult.close(); + } catch (err) { + console.error('getExifDemoCallback failed with error: ' + err); + } +} +``` + +### setUserComment10+ + +setUserComment(userComment: string): Promise<void> + +Sets user comment information of an image or video. This API uses a promise to return the result. + +**NOTE**
This API can be used to modify the comment information of only images or videos. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO + +**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| userComment | string | Yes | User comment information to set, which cannot exceed 140 characters.| + +**Return value** + +| Type | Description | +| --------------------------------------- | ----------------- | +|Promise<void> | Promise that returns no value.| + +**Example** + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +async function example() { + try { + console.info('setUserCommentDemo') + let predicates = new dataSharePredicates.DataSharePredicates(); + let fetchOptions = { + fetchColumns: [], + predicates: predicates + }; + let fetchResult = await phAccessHelper.getAssets(fetchOptions); + let fileAsset = await fetchResult.getFirstObject(); + let userComment = 'test_set_user_comment'; + await fileAsset.setUserComment(userComment); + } catch (err) { + console.error('setUserCommentDemoCallback failed with error: ' + err); + } +} +``` + +### setUserComment10+ + +setUserComment(userComment: string, callback: AsyncCallback<void>): void + +Sets user comment information of an image or video. This API uses an asynchronous callback to return the result. + +**NOTE**
This API can be used to modify the comment information of only images or videos. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO + +**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| userComment | string | Yes | User comment information to set, which cannot exceed 140 characters.| +| callback | AsyncCallback<void> | Yes | Callback that returns no value.| + +**Example** + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +async function example() { + try { + console.info('setUserCommentDemo') + let predicates = new dataSharePredicates.DataSharePredicates(); + let fetchOptions = { + fetchColumns: [], + predicates: predicates + }; + let fetchResult = await phAccessHelper.getAssets(fetchOptions); + let fileAsset = await fetchResult.getFirstObject(); + let userComment = 'test_set_user_comment'; + fileAsset.setUserComment(userComment, (err) => { + if (err === undefined) { + console.info('setUserComment successfully'); + } else { + console.error('setUserComment failed with error: ' + err); + } + }); + } catch (err) { + console.error('setUserCommentDemoCallback failed with error: ' + err); + } +} +``` + ## FetchResult Provides APIs to manage the file retrieval result. @@ -3726,6 +4147,7 @@ Defines the key information about an image or video file. | DATE_TRASHED | 'date_trashed' | Date when the file was deleted. The value is the number of seconds between the time when the file is deleted and January 1, 1970. **System API**: This is a system API. | | HIDDEN | 'hidden' | Whether the file is hidden. **System API**: This is a system API. | | CAMERA_SHOT_KEY | 'camera_shot_key' | Key for the Untra Snamshot feature, which allows the camera to take photos or record videos with the screen off. (This parameter is available only for the system camera, and the key value is defined by the system camera.)
**System API**: This is a system API. | +| USER_COMMENT10+ | 'user_comment' | User comment information. **System API**: This is a system API. | ## AlbumKeys diff --git a/en/application-dev/reference/apis/js-apis-secureElement.md b/en/application-dev/reference/apis/js-apis-secureElement.md index 4314ea8176..daa96f217b 100644 --- a/en/application-dev/reference/apis/js-apis-secureElement.md +++ b/en/application-dev/reference/apis/js-apis-secureElement.md @@ -66,7 +66,7 @@ try { if (state == secureElement.ServiceState.DISCONNECTED) { console.log("Service state is Disconnected"); } else { - console.log.("Service state is Connected"); + console.log("Service state is Connected"); } }); } catch (e) { @@ -114,7 +114,6 @@ try { try { nfcOmaReaderList = nfcSEService.getReaders(); if (nfcOmaReaderList != null && nfcOmaReaderList.length > 0) { - nfcOmaReader = this.nfcOmaReaderList[0]; console.log("get reader successfully"); } else { console.log("get reader failed"); @@ -205,7 +204,6 @@ import secureElement from '@ohos.secureElement'; let nfcSEService = null; -this.result = "version: " try { // refer to newSEService for this.nfcSEService console.log("version: " + nfcSEService.getVersion()); @@ -349,7 +347,7 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -nfcOmaReader = null; +let nfcOmaReader = null; try { // refer to SEService.getReaders for this.nfcOmaReader @@ -584,10 +582,11 @@ import secureElement from '@ohos.secureElement'; let nfcOmaSession = null; let nfcOmaChannel = null; +let aidArray = [720, 1080]; try { // See Reader.openSession for this.nfcOmaSession. - let getPromise = nfcOmaSession.openBasicChannel(this.aidArray); + let getPromise = nfcOmaSession.openBasicChannel(aidArray); getPromise.then((channel) => { nfcOmaChannel = channel; console.log("openBasicChannel1 get channel successfully"); @@ -737,7 +736,6 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; - let nfcOmaSession = null; let nfcOmaChannel = null; let aidArray = [720, 1080]; @@ -915,8 +913,9 @@ if (nfcOmaSession) { }).catch ((err) => { console.log("openLogicChannel3 exception"); }) -} catch (e) { - console.log("openLogicChannel3 exception:" + e.message); + } catch (e) { + console.log("openLogicChannel3 exception:" + e.message); + } } ``` diff --git a/en/application-dev/reference/apis/js-apis-userFileManager.md b/en/application-dev/reference/apis/js-apis-userFileManager.md index d3732ddaf1..ba865a7568 100644 --- a/en/application-dev/reference/apis/js-apis-userFileManager.md +++ b/en/application-dev/reference/apis/js-apis-userFileManager.md @@ -1393,6 +1393,151 @@ async function example() { } ``` +### getPhotoIndex10+ + +getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions, callback: AsyncCallback<number>): void + +Obtains the index of an image or video in an album. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_IMAGEVIDEO + +**System capability**: SystemCapability.FileManagement.UserFileManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| photoUri | string | Yes | URI of the media asset whose index is to be obtained.| +| albumUri | string | Yes | Album URI, which can be an empty string. If it is an empty string, all the media assets in the Gallery are obtained by default. | +| options | [FetchOptions](#fetchoptions) | Yes | Fetch options. Only one search condition or sorting mode must be set in **predicates**. If no value is set or multiple search conditions or sorting modes are set, the API cannot be called successfully. | + +**Return value** + +| Type | Description | +| --------------------------------------- | ----------------- | +| AsyncCallback<number>| Callback invoked to return the index obtained.| + +**Error codes** + +For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md). + +| ID| Error Message| +| -------- | ---------------------------------------- | +| 401 | if parameter is invalid. | + +**Example** + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +async function example() { + console.info('getPhotoIndexDemo'); + let predicatesForGetAsset = new dataSharePredicates.DataSharePredicates(); + let fetchOp = { + fetchColumns: [], + predicates: predicatesForGetAsset + }; + //Obtain the uri of the album + let albumFetchResult = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubtype.FAVORITE, fetchOp); + let album = await albumFetchResult.getFirstObject(); + + let predicates = new dataSharePredicates.DataSharePredicates(); + predicates.orderByAsc("add_modified"); + let fetchOptions = { + fetchColumns: [], + predicates: predicates + }; + let photoFetchResult = await album.getPhotoAssets(fetchOptions); + let expectIndex = 1; + //Obtain the uri of the second file + let photoAsset = await photoFetchResult.getPositionObject(expectIndex); + + mgr.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions, (err, index) => { + try { + if (err == undefined) { + console.info(`getPhotoIndex successfully and index is : ${index}`); + } else { + console.info(`getPhotoIndex failed;`); + } + } catch (error) { + console.info(`getPhotoIndex failed; error: ${error}`); + } + } +} +``` + +### getPhotoIndex10+ + +getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions): Promise<number> + +Obtains the index of an image or video in an album. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_IMAGEVIDEO + +**System capability**: SystemCapability.FileManagement.UserFileManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| photoUri | string | Yes | URI of the media asset whose index is to be obtained.| +| albumUri | string | Yes | Album URI, which can be an empty string. If it is an empty string, all the media assets in the Gallery are obtained by default. | +| options | [FetchOptions](#fetchoptions) | Yes | Fetch options. Only one search condition or sorting mode must be set in **predicates**. If no value is set or multiple search conditions or sorting modes are set, the API cannot be called successfully. | + +**Return value** + +| Type | Description | +| --------------------------------------- | ----------------- | +| Promise<number>| Promise used to return the index obtained.| + +**Error codes** + +For details about the error codes, see [Universal Error Codes](../errorcodes/errorcode-universal.md). + +| ID| Error Message| +| -------- | ---------------------------------------- | +| 401 | if parameter is invalid. | + +**Example** + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +async function example() { + console.info('getPhotoIndexDemo'); + let predicatesForGetAsset = new dataSharePredicates.DataSharePredicates(); + let fetchOp = { + fetchColumns: [], + predicates: predicatesForGetAsset + }; + //Obtain the uri of the album + let albumFetchResult = await mgr.getAlbums(userFileManager.AlbumType.SYSTEM, userFileManager.AlbumSubtype.FAVORITE, fetchOp); + let album = await albumFetchResult.getFirstObject(); + + let predicates = new dataSharePredicates.DataSharePredicates(); + predicates.orderByAsc("add_modified"); + let fetchOptions = { + fetchColumns: [], + predicates: predicates + }; + let photoFetchResult = await album.getPhotoAssets(fetchOptions); + let expectIndex = 1; + //Obtain the uri of the second file + let photoAsset = await photoFetchResult.getPositionObject(expectIndex); + + mgr.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions) + .then((index) => { + console.info(`getPhotoIndex successfully and index is : ${index}`); + }).catch((err) => { + console.info(`getPhotoIndex failed; error: ${err}`); + }) +} +``` + ### release release(callback: AsyncCallback<void>): void @@ -1684,7 +1829,7 @@ Provides APIs for encapsulating file asset attributes. | Name | Type | Readable| Writable| Description | | ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ | -| uri | string | Yes | No | File asset URI, for example, **file://media/image/2**. | +| uri | string | Yes | No | File asset URI, for example, **file://media/Photo/1/IMG_datetime_0001/displayName.jpg**. | | fileType | [FileType](#filetype) | Yes | No | Type of the file. | | displayName | string | Yes | Yes | File name, including the file name extension, to display. | @@ -2350,6 +2495,282 @@ async function example() { } ``` +### getExif10+ + +getExif(): Promise<string> + +Obtains a JSON string consisting of the exchangeable image file format (EXIF) tags of this JPG image. This API uses a promise to return the result. + +**CAUTION**
This API returns a JSON string consisting of EXIF tags. The complete EXIF information consists of **all_exif** and **ImageVideoKey.USER_COMMENT**. These two fields must be passed in via **fetchColumns**. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_IMAGEVIDEO + +**System capability**: SystemCapability.FileManagement.UserFileManager.Core + +**Return value** + +| Type | Description | +| --------------------------------------- | ----------------- | +| Promise<string> | Promise used to return the JSON string obtained.| + +**Supported EXIF tags** + +For details about the EXIF tags, see [image.PropertyKey](js-apis-image.md#propertykey7). + +| Key Value | Description | +| --------------------------------------- | ----------------- | +| BitsPerSample | Number of bits per pixel.| +| Orientation | Image orientation.| +| ImageLength | Image length.| +| ImageWidth | Image width.| +| GPSLatitude | GPS latitude of the image.| +| GPSLongitude | GPS longitude of the image.| +| GPSLatitudeRef | Longitude reference, for example, W or E.| +| GPSLongitudeRef | Latitude reference, for example, N or S.| +| DateTimeOriginal | Shooting time.| +| ExposureTime | Exposure time.| +| SceneType | Shooting scene type.| +| ISOSpeedRatings | ISO sensitivity or speed.| +| FNumber | f-number.| +| DateTime | Date and time when the image was last modified.| +| GPSTimeStamp | GPS timestamp.| +| GPSDateStamp | GPS date stamp.| +| ImageDescription | Image description.| +| Make | Camera vendor.| +| Model | Model.| +| PhotoMode | Photo mode.| +| SensitivityType | Sensitivity type.| +| StandardOutputSensitivity | Standard output sensitivity.| +| RecommendedExposureIndex | Recommended exposure index.| +| ApertureValue | Aperture value.| +| MeteringMode | Metering mode.| +| LightSource | Light source.| +| Flash | Flash status.| +| FocalLength | Focal length.| +| UserComment | User comment.| +| PixelXDimension | Pixel X dimension.| +| PixelYDimension | Pixel Y dimension.| +| WhiteBalance | White balance.| +| FocalLengthIn35mmFilm | Focal length in 35 mm film.| +| ExposureBiasValue | Exposure compensation.| + +**Example** + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +async function example() { + try { + console.info('getExifDemo'); + let predicates = new dataSharePredicates.DataSharePredicates(); + let fetchOptions = { + fetchColumns: [ 'all_exif', ImageVideoKey.USER_COMMENT], + predicates: predicates + }; + let fetchResult = await mgr.getPhotoAssets(fetchOptions); + let fileAsset = await fetchResult.getFirstObject(); + let exifMessage = await fileAsset.getExif(); + let userCommentKey = 'UserComment'; + let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]); + fetchResult.close(); + } catch (err) { + console.error('getExifDemoCallback failed with error: ' + err); + } +} +``` + +### getExif10+ + +getExif(callback: AsyncCallback<string>): void + +Obtains a JSON string consisting of the EXIF tags of this JPG image. This API uses an asynchronous callback to return the result. + +**CAUTION**
This API returns a JSON string consisting of EXIF tags. The complete EXIF information consists of **all_exif** and **ImageVideoKey.USER_COMMENT**. These two fields must be passed in via **fetchColumns**. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.READ_IMAGEVIDEO + +**System capability**: SystemCapability.FileManagement.UserFileManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<string> | Yes | Callback invoked to return the JSON string obtained.| + +**Supported EXIF tags** + +For details about the EXIF tags, see [image.PropertyKey](js-apis-image.md#propertykey7). + +| Key Value | Description | +| --------------------------------------- | ----------------- | +| BitsPerSample | Number of bits per pixel.| +| Orientation | Image orientation.| +| ImageLength | Image length.| +| ImageWidth | Image width.| +| GPSLatitude | GPS latitude of the image.| +| GPSLongitude | GPS longitude of the image.| +| GPSLatitudeRef | Longitude reference, for example, W or E.| +| GPSLongitudeRef | Latitude reference, for example, N or S.| +| DateTimeOriginal | Shooting time.| +| ExposureTime | Exposure time.| +| SceneType | Shooting scene type.| +| ISOSpeedRatings | ISO sensitivity or speed.| +| FNumber | f-number.| +| DateTime | Date and time when the image was last modified.| +| GPSTimeStamp | GPS timestamp.| +| GPSDateStamp | GPS date stamp.| +| ImageDescription | Image description.| +| Make | Camera vendor.| +| Model | Model.| +| PhotoMode | Photo mode.| +| SensitivityType | Sensitivity type.| +| StandardOutputSensitivity | Standard output sensitivity.| +| RecommendedExposureIndex | Recommended exposure index.| +| ApertureValue | Aperture value.| +| MeteringMode | Metering mode.| +| LightSource | Light source.| +| Flash | Flash status.| +| FocalLength | Focal length.| +| UserComment | User comment.| +| PixelXDimension | Pixel X dimension.| +| PixelYDimension | Pixel Y dimension.| +| WhiteBalance | White balance.| +| FocalLengthIn35mmFilm | Focal length in 35 mm film.| +| ExposureBiasValue | Exposure compensation.| + +**Example** + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +async function example() { + try { + console.info('getExifDemo'); + let predicates = new dataSharePredicates.DataSharePredicates(); + let fetchOptions = { + fetchColumns: [ 'all_exif', ImageVideoKey.USER_COMMENT], + predicates: predicates + }; + let fetchResult = await mgr.getPhotoAssets(fetchOptions); + let fileAsset = await fetchResult.getFirstObject(); + let userCommentKey = 'UserComment'; + fileAsset.getExif((err, exifMessage) => { + if (exifMessage != undefined) { + let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]); + } else { + console.error('getExif failed, message = ', err); + } + }); + fetchResult.close(); + } catch (err) { + console.error('getExifDemoCallback failed with error: ' + err); + } +} +``` + +### setUserComment10+ + +setUserComment(userComment: string): Promise<void> + +Sets user comment information of an image or video. This API uses a promise to return the result. + +**NOTE**
This API can be used to modify the comment information of only images or videos. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO + +**System capability**: SystemCapability.FileManagement.UserFileManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| userComment | string | Yes | User comment information to set, which cannot exceed 140 characters.| + +**Return value** + +| Type | Description | +| --------------------------------------- | ----------------- | +|Promise<void> | Promise that returns no value.| + +**Example** + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +async function example() { + try { + console.info('setUserCommentDemo') + let predicates = new dataSharePredicates.DataSharePredicates(); + let fetchOptions = { + fetchColumns: [], + predicates: predicates + }; + let fetchResult = await mgr.getPhotoAssets(fetchOptions); + let fileAsset = await fetchResult.getFirstObject(); + let userComment = 'test_set_user_comment'; + await fileAsset.setUserComment(userComment); + } catch (err) { + console.error('setUserCommentDemoCallback failed with error: ' + err); + } +} +``` + +### setUserComment10+ + +setUserComment(userComment: string, callback: AsyncCallback<void>): void + +Sets user comment information of an image or video. This API uses an asynchronous callback to return the result. + +**NOTE**
This API can be used to modify the comment information of only images or videos. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO + +**System capability**: SystemCapability.FileManagement.UserFileManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ---------- | +| userComment | string | Yes | User comment information to set, which cannot exceed 140 characters.| +| callback | AsyncCallback<void> | Yes | Callback that returns no value.| + +**Example** + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +async function example() { + try { + console.info('setUserCommentDemo') + let predicates = new dataSharePredicates.DataSharePredicates(); + let fetchOptions = { + fetchColumns: [], + predicates: predicates + }; + let fetchResult = await mgr.getPhotoAssets(fetchOptions); + let fileAsset = await fetchResult.getFirstObject(); + let userComment = 'test_set_user_comment'; + fileAsset.setUserComment(userComment, (err) => { + if (err === undefined) { + console.info('setUserComment successfully'); + } else { + console.error('setUserComment failed with error: ' + err); + } + }); + } catch (err) { + console.error('setUserCommentDemoCallback failed with error: ' + err); + } +} +``` + ## FetchResult Provides APIs to manage the file retrieval result. @@ -3962,6 +4383,7 @@ Defines the key information about an image or video file. | DATE_TRASHED10+ | date_trashed | Date when the file was deleted. The value is the number of seconds between the time when the file is deleted and January 1, 1970. | | HIDDEN10+ | hidden | Whether the file is hidden. | | CAMERA_SHOT_KEY10+ | camera_shot_key | Key for the Untra Snamshot feature, which allows the camera to take photos or record videos with the screen off. (This parameter is available only for the system camera, and the key value is defined by the system camera.) | +| USER_COMMENT10+ | user_comment | User comment information. | ## AlbumKey diff --git a/en/application-dev/reference/apis/js-apis-useriam-userauth.md b/en/application-dev/reference/apis/js-apis-useriam-userauth.md index a5771cf5e7..84dacee24d 100644 --- a/en/application-dev/reference/apis/js-apis-useriam-userauth.md +++ b/en/application-dev/reference/apis/js-apis-useriam-userauth.md @@ -1054,7 +1054,7 @@ Checks whether the specified authentication capability is supported. | Name | Type | Mandatory| Description | | -------------- | ---------------------------------- | ---- | -------------------------- | -| authType | [UserAuthType](#userauthtype8) | Yes | Authentication type. Only **FACE** is supported.| +| authType | [UserAuthType](#userauthtype8) | Yes | Authentication type.| | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | Yes | Authentication trust level. | **Error codes** diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-account_os_account.md b/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-account_os_account.md new file mode 100644 index 0000000000..4a3cc8ed63 --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-account_os_account.md @@ -0,0 +1,56 @@ +# Account Subsystem Changelog + +## cl.account_os_account.1 Deletion of App Account Authorization Interfaces + +**Change Impact** + +Apps developed based on earlier versions cannot use the account authorization capability. + +**Key API/Component Changes** + +Involved interfaces: + +interface/sdk-js/api/@ohos.account.appAccount.d.ts: + +```js + enum AccountCapabilityType +``` +```js + class AccountCapabilityProvider +``` +```js + class AuthorizationProvider extends AccountCapabilityProvider +``` +```js + interface AuthorizationProviderInfo +``` +```js + class AccountCapabilityRequest +``` +```js + class AccountCapabilityResponse +``` +```js + class AccountCapabilityScheduler +``` + +interface/sdk-js/api/@ohos.account.appAccount.AuthorizationExtensionAbility.d.ts: + +```js + export default class AuthorizationExtensionAbility extends ExtensionAbility +``` +```js + declare interface AuthorizationRequest +``` +```js + declare interface AuthorizationCallback +``` + + +After change: + +All the involved interfaces are deleted. + +**Adaptation Guide** + +The deleted interfaces cannot be used any longer. Delete the corresponding functions accordingly. diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-cert.md b/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-cert.md index 2b159c78eb..d571d0c01b 100644 --- a/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-cert.md +++ b/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-cert.md @@ -6,11 +6,11 @@ Deprecated **X509Cert.getSerialNumber()** and replaced it with **X509Cert.getCer **Change Impact** -**X509Cert.getSerialNumber()** is deprecated since API version 10. **X509Cert.getCertSerialNumber()** should be used to replace **X509Cert.getSerialNumber()** in application development. The API function remains unchanged. +Since API version 10, use **X509Cert.getCertSerialNumber()** instead of **X509Cert.getSerialNumber()** in application development. The API function remains unchanged. **Key API/Component Changes** -API before change: +Before change: ```js interface X509Cert { @@ -20,7 +20,7 @@ interface X509Cert { } ``` -API after change: +After change: ```js interface X509Cert { diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-wifiManager.md b/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-wifiManager.md new file mode 100644 index 0000000000..2a685b6464 --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-wifiManager.md @@ -0,0 +1,47 @@ +# Wi-Fi Subsystem Changelog + +## 1 Permission Change + +1. The location permission is not required if a random MAC is returned. +1. The GET_WIFI_PEERS_MAC permission is required if a real MAC address is returned. + +| API| Permission| +| -------- | ---------------------------- | +|**function** getCandidateConfigs(): Array; | 1. The location permission is not required.| +|**function** getDeviceConfigs(): Array; | 1. The location permission is not required.| +|**function** getStations(): Array; | 1. The location permission is not required.
2. A random MAC address is returned (the GET_WIFI_PEERS_MAC permission is required if a real MAC address is returned). | +| **function** getCurrentP2pGroup(): Promise; | 1. The location permission is not required.| +| **function** getCurrentP2pGroup(callback: AsyncCallback): **void**; | 1. The location permission is not required.| +| **function** getP2pPeerDevices(): Promise; | 1. The location permission is not required.
2. A random MAC address is returned (the GET_WIFI_PEERS_MAC permission is required if a real MAC address is returned). | +| **function** getP2pPeerDevices(callback: AsyncCallback): **void**; | 1. The location permission is not required.
2. A random MAC address is returned (the GET_WIFI_PEERS_MAC permission is required if a real MAC address is returned). | +| **function** p2pConnect(config: WifiP2PConfig): **void**; | 1. The location permission is not required.| +| **function** startDiscoverDevices(): **void**; | 1. The location permission is not required.| +| **function** getP2pGroups(): Promise>; | 1. The location permission is not required.| +| **function** getP2pGroups(callback: AsyncCallback>): **void**; | 1. The location permission is not required.| +| **function** on(**type**: "p2pDeviceChange", callback: Callback): **void**; | 1. The location permission is not required.
2. A random MAC address is returned (the GET_WIFI_PEERS_MAC permission is required if a real MAC address is returned). | +| **function** off(**type**: "p2pDeviceChange", callback?: Callback): **void**; | 1. The location permission is not required.
2. A random MAC address is returned (the GET_WIFI_PEERS_MAC permission is required if a real MAC address is returned). | +| **function** on(**type**: "p2pPeerDeviceChange", callback: Callback): **void**; | 1. The location permission is not required.
2. A random MAC address is returned (the GET_WIFI_PEERS_MAC permission is required if a real MAC address is returned). | +| **function** off(**type**: "p2pPeerDeviceChange", callback?: Callback): **void**; | 1. The location permission is not required.
2. A random MAC address is returned (the GET_WIFI_PEERS_MAC permission is required if a real MAC address is returned). | + + +## 2 Added APIs +| API| Description| +|------|---------| +| **function** startScan(): **void**; | Starts a scan.| +| **function** getScanInfoList(): Array; | Obtains the scan list. | +| **function** setScanAlwaysAllowed(isScanAlwaysAllowed: boolean): **void**; | Sets whether to always allow Wi-Fi scanning. | +| **function** getScanAlwaysAllowed(): boolean; | Obtains the Wi-Fi scan settings on the background. | +| **function** getIpv6Info(): Ipv6Info; | Obtains IPv6 address information. | +| **function** isBandTypeSupported(bandType: WifiBandType): boolean; | Checks whether BandType is supported.| +| **function** get5GChannelList(): Array<**number**>; | Obtains the 5G channel list. | +| **function** getDisconnectedReason(): DisconnectedReason; | Obtains the reason for network disconnection. | + +## 3 Deprecated APIs + + +| API |Description | +| ------------- |-------------------------------------------------------- | +| **function** scan(): **void**; | Use **startScan** instead.| +| **function** getScanResults(): Promise>; | Use **getScanInfoList** instead.| +| **function** getScanResults(callback: AsyncCallback>): **void**; | Use **getScanInfoList** instead.| +| **function** getScanResultsSync(): Array; | Use **getScanInfoList** instead.| -- GitLab