“7fd15ce5394c937fc4bc0be790b0f542640f1702”上不存在“python/git@gitcode.net:s920243400/PaddleDetection.git”
提交 f16dfa24 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 48a166fc
# Preferences # Preferences
Preferences provide capabilities for processing data in the form of key-value (KV) pairs and supports lightweight data persistence, modification, and query. In KV pairs, keys are of the string type, and values can be of the number, string, or Boolean type. Preferences provide capabilities for processing data in the form of key-value (KV) pairs and support lightweight data persistence, modification, and query. In KV pairs, keys are of the string type, and values can be of the number, string, or Boolean type.
> **NOTE**<br/> > **NOTE**<br/>
...@@ -19,8 +19,8 @@ import data_preferences from '@ohos.data.preferences'; ...@@ -19,8 +19,8 @@ import data_preferences from '@ohos.data.preferences';
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| MAX_KEY_LENGTH | string | Yes| No| Maximum length of a key. It is 80 bytes.| | MAX_KEY_LENGTH | string | Yes| No| Maximum length of a key. It must be less than 80 bytes.|
| MAX_VALUE_LENGTH | string | Yes| No| Maximum length of a value. It is 8192 bytes.| | MAX_VALUE_LENGTH | string | Yes| No| Maximum length of a value. It must be less than 8192 bytes.|
## data_preferences.getPreferences ## data_preferences.getPreferences
...@@ -262,6 +262,56 @@ promise.then((value) => { ...@@ -262,6 +262,56 @@ promise.then((value) => {
}) })
``` ```
### getAll
getAll(callback: AsyncCallback&lt;Object&gt;): void;
Obtains the **Object** instance that contains all values.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Object&gt; | Yes| Callback used to return the **Object** instance that contains all values.|
**Example**
```ts
preferences.get.getAll(function (err, value) {
if (err) {
console.info("getAll failed, err: " + err)
return
}
let keys = Object.keys(value)
console.info('getAll keys = ' + keys)
console.info("getAll object = " + JSON.stringify(value))
});
```
### getAll
getAll(): Promise&lt;Object&gt;
Obtains the **Object** instance that contains all values.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Object&gt; | Promise used to return the **Object** instance that contains all values.|
**Example**
```ts
let promise = preferences.getAll()
promise.then((value) => {
let keys = Object.keys(value)
console.info('getAll keys = ' + keys)
console.info("getAll object = " + JSON.stringify(value))
}).catch((err) => {
console.info("getAll failed, err: " + err)
})
```
### put ### put
...@@ -289,7 +339,6 @@ preferences.put('startup', 'auto', function (err) { ...@@ -289,7 +339,6 @@ preferences.put('startup', 'auto', function (err) {
}) })
``` ```
### put ### put
put(key: string, value: ValueType): Promise&lt;void&gt; put(key: string, value: ValueType): Promise&lt;void&gt;
...@@ -322,7 +371,7 @@ promise.then(() => { ...@@ -322,7 +371,7 @@ promise.then(() => {
### has ### has
has(key: string, callback: AsyncCallback&lt;boolean&gt;): boolean has(key: string, callback: AsyncCallback&lt;boolean&gt;): void
Checks whether this **Preferences** instance contains data with a given key. This API uses an asynchronous callback to return the result. Checks whether this **Preferences** instance contains data with a given key. This API uses an asynchronous callback to return the result.
...@@ -332,12 +381,8 @@ Checks whether this **Preferences** instance contains data with a given key. Thi ...@@ -332,12 +381,8 @@ Checks whether this **Preferences** instance contains data with a given key. Thi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to check. It cannot be empty.| | key | string | Yes| Key of the data to check. It cannot be empty.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. It returns **true** if the **Preferences** instance contains data with the given key and returns **false** otherwise.|
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the **Preferences** instance contains data with the specified key; returns **false** otherwise.|
**Example** **Example**
```ts ```ts
...@@ -371,7 +416,7 @@ Checks whether this **Preferences** instance contains data with a given key. Thi ...@@ -371,7 +416,7 @@ Checks whether this **Preferences** instance contains data with a given key. Thi
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result.| | Promise&lt;boolean&gt; | Promise used to return the result. It returns **true** if the **Preferences** instance contains data with the given key and returns **false** otherwise.|
**Example** **Example**
```ts ```ts
...@@ -550,10 +595,10 @@ Subscribes to data changes. When the value of the subscribed key changes, a call ...@@ -550,10 +595,10 @@ Subscribes to data changes. When the value of the subscribed key changes, a call
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Description| | Name| Type|Mandatory| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |-------- |
| type | string | Event type. The value **change** indicates data change events.| | type | string | Yes| Event type. The value **change** indicates data change events.|
| callback | Callback&lt;{ key : string }&gt; | Callback used to return data changes.| | callback | Callback&lt;{ key : string }&gt; | Yes| Callback used to return data changes.|
**Example** **Example**
```ts ```ts
...@@ -584,17 +629,17 @@ preferences.put('startup', 'auto', function (err) { ...@@ -584,17 +629,17 @@ preferences.put('startup', 'auto', function (err) {
### off('change') ### off('change')
off(type: 'change', callback: Callback&lt;{ key : string }&gt;): void off(type: 'change', callback?: Callback&lt;{ key : string }&gt;): void
Unsubscribes from data changes. Unsubscribes from data changes.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** **Parameters**
| Name| Type| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |-------- |
| type | string | Event type. The value **change** indicates data change events.| | type | string| Yes| Event type. The value **change** indicates data change events.|
| callback | Callback&lt;{ key : string }&gt; | Callback used to return data changes.| | callback | Callback&lt;{ key : string }&gt; | No| Callback used to return data changes. If this parameter is left empty, all callbacks for data changes will be canceled.|
**Example** **Example**
```ts ```ts
......
...@@ -22,15 +22,15 @@ import dataStorage from '@ohos.data.storage'; ...@@ -22,15 +22,15 @@ import dataStorage from '@ohos.data.storage';
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| MAX_KEY_LENGTH | string | Yes| No| Maximum length of a key. It is 80 bytes.| | MAX_KEY_LENGTH | string | Yes| No| Maximum length of a key. It must be less than 80 bytes.|
| MAX_VALUE_LENGTH | string | Yes| No| Maximum length of a value. It is 8192 bytes.| | MAX_VALUE_LENGTH | string | Yes| No| Maximum length of a value. It must be less than 8192 bytes.|
## dataStorage.getStorageSync ## dataStorage.getStorageSync
getStorageSync(path: string): Storage getStorageSync(path: string): Storage
Reads the specified file and load its data to the **Storage** instance for data operations. Reads the specified file and loads its data to the **Storage** instance for data operations.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
......
...@@ -68,7 +68,7 @@ Sets the value in the cache based on the specified key. ...@@ -68,7 +68,7 @@ Sets the value in the cache based on the specified key.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to set.| | key | string | Yes| Key of the data to set.|
| value | string | Yes| New value to set. The maximum length is 128 bytes.| | value | string | Yes| New value to set. The length must be less than 128 bytes.|
| success | Function | No| Called when **storage.set()** is successful.| | success | Function | No| Called when **storage.set()** is successful.|
| fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.| | fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
| complete | Function | No| Called when **storage.set()** is complete.| | complete | Function | No| Called when **storage.set()** is complete.|
......
...@@ -4,20 +4,20 @@ ...@@ -4,20 +4,20 @@
### Function ### Function
Personal Identification Number (PIN) authentication provides user authentication capabilities in identity authentication scenarios, such as device unlocking, payment, and app logins. After a user registers a PIN, the PIN authentication (pin_auth) module unlocks the device only when a correct PIN is entered. The figure below shows the architecture of PIN authentication. Personal Identification Number (PIN) authentication provides user authentication capabilities in identity authentication scenarios, such as device unlocking, payment, and app logins. After a user registers a PIN, the PIN authentication (Pin_auth) module unlocks the device only when a correct PIN is entered. The figure below shows the architecture of PIN authentication.
The pin_auth driver is developed based on the Hardware Driver Foundation (HDF). The pin_auth driver model shields hardware differences and provides stable PIN authentication capabilities for the user IAM framework(UserIAM) and PIN authentication system ability (SA). The PIN authentication capabilities include obtaining the PIN authentication executor list, executor information, and anti-brute force information of the specified template, comparing the template list of the executor and that of UserIAM, enrolling or deleting PINs, and performing PIN authentication. The Pin_auth driver is developed based on the Hardware Driver Foundation (HDF). The Pin_auth driver model shields hardware differences and provides stable PIN authentication capabilities for the user User_auth framework (User_auth) and PIN authentication system ability (SA). The PIN authentication capabilities include obtaining the PIN authentication executor list, executor information, and anti-brute force information of the specified template, comparing the template ID list of the executor and that of User_auth, enrolling or deleting PINs, and performing PIN authentication.
**Figure 1** PIN authentication architecture **Figure 1** PIN authentication architecture
![image](figures/pin_auth_architecture.png "PIN authentication architecture") ![image](figures/pin_auth_architecture.png "PIN authentication architecture")
### Basic Concepts ### Basic Concepts
The identity authentication consists of UserIAM and basic authentication services (including PIN authentication and facial recognition). It supports basic functions such as setting and deleting user credentials, and performing authentication. The identity authentication consists of User_auth and basic authentication services (including PIN authentication and facial recognition). It supports basic functions such as setting and deleting user credentials and performing authentication.
- Executor - Executor
The executor collects, processes, stores, and compares data for authentication. Each authentication service provides the executor capabilities, which are scheduled by UserIAM to implement basic capabilities. The executor collects, processes, stores, and compares data for authentication. Each authentication service provides the executor capabilities, which are scheduled by User_auth to implement basic capabilities.
- Executor security level - Executor security level
...@@ -35,13 +35,13 @@ The identity authentication consists of UserIAM and basic authentication service ...@@ -35,13 +35,13 @@ The identity authentication consists of UserIAM and basic authentication service
The authentication algorithm varies depending on the authentication mode and device used. Different executor types are defined based on the supported algorithm type or the device in use. The authentication algorithm varies depending on the authentication mode and device used. Different executor types are defined based on the supported algorithm type or the device in use.
- UserIAM public key & executor public key - User_auth public key & executor public key
To ensure user data security and authentication result accuracy, measures must be taken to protect the integrity of the key information exchanged between UserIAM and basic authentication services. Public keys must be exchanged when the executor provided by a basic authentication service interworks with UserIAM. To ensure user data security and authentication result accuracy, measures must be taken to protect the integrity of the key information exchanged between User_auth and basic authentication services. Public keys must be exchanged when the executor provided by a basic authentication service interworks with User_auth.
- The executor uses the UserIAM public key to verify the scheduling instruction. - The executor uses the User_auth public key to verify scheduling instructions.
- UserIAM uses the executor public key to verify the authentication result accuracy and the integrity of the information exchanged with the executor. - User_auth uses the executor public key to verify the authentication result accuracy and the integrity of the information exchanged with the executor.
- PIN authentication credential template - PIN authentication credential template
...@@ -50,22 +50,22 @@ The identity authentication consists of UserIAM and basic authentication service ...@@ -50,22 +50,22 @@ The identity authentication consists of UserIAM and basic authentication service
- Data verification by the executor - Data verification by the executor
UserIAM manages the mappings between user identities and credential IDs in a unified manner. When connecting to UserIAM, the executor obtains the template ID list from UserIAM, and updates its template ID list based on the obtained template ID list. User_auth manages the mappings between user identities and credential IDs in a unified manner. When connecting to User_auth, the executor obtains the template ID list from User_auth and updates its template ID list based on the template ID list obtained.
### Working Principles ### Working Principles
The pin_auth driver provides basic capabilities of PIN authentication for the upper-layer UserIAM and pin_auth service to ensure successful PIN authentication. You can develop drivers to call Hardware Device Interface (HDI) APIs based on the HDF and the chip you use. The Pin_auth driver provides basic PIN authentication capabilities for the upper-layer User_auth and Pin_auth service to ensure successful PIN authentication. You can develop drivers to call Hardware Device Interface (HDI) APIs based on the HDF and the chip you use.
**Figure 2** Pin_auth service and pin_auth driver APIs **Figure 2** Pin_auth service and pin_auth driver APIs
![image](figures/pin_auth_service_and_driver_interaction.png "interaction between the pin_auth service and driver") ![image](figures/pin_auth_service_and_driver_interaction.png "interaction between the Pin_auth service and driver")
### Constraints ### Constraints
PIN authentication must be implemented in a TEE, and the confidential information, such as PINs and credentials, must be stored in a TEE. PIN authentication must be implemented in a TEE, and the confidential information, such as PINs and credentials, must be stored in a TEE.
## Development Guidelines ## Development Guidelines
### When to Use ### When to Use
The pin_auth driver provides basic PIN authentication capabilities for the UserIAM and pin_auth service to ensure successful PIN authentication. The Pin_auth driver provides basic PIN authentication capabilities for the User_auth and Pin_auth service to ensure successful PIN authentication.
### Available APIs ### Available APIs
...@@ -76,7 +76,7 @@ The pin_auth driver provides basic PIN authentication capabilities for the UserI ...@@ -76,7 +76,7 @@ The pin_auth driver provides basic PIN authentication capabilities for the UserI
| GetExecutorList(std::vector<sptr<IExecutor>>& executorList) | Obtains the executor list. | | GetExecutorList(std::vector<sptr<IExecutor>>& executorList) | Obtains the executor list. |
| GetExecutorInfo(ExecutorInfo& info) | Obtains information about an executor. | | GetExecutorInfo(ExecutorInfo& info) | Obtains information about an executor. |
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | Obtains information about a template. | | GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | Obtains information about a template. |
| OnRegisterFinish(const std::vector<uint64_t>& templateIdList,<br>const std::vector<uint8_t>& frameworkPublicKey,<br>const std::vector<uint8_t>& extraInfo) | Obtains the public key and template list from UserIAM after the executor is registered successfully.| | OnRegisterFinish(const std::vector<uint64_t>& templateIdList,<br>const std::vector<uint8_t>& frameworkPublicKey,<br>const std::vector<uint8_t>& extraInfo) | Obtains the public key and template ID list from User_auth after the executor is registered successfully.|
| OnSetData(uint64_t scheduleId, uint64_t authSubType, <br>const std::vector<uint8_t> &data) | Called to return the subtype and anonymized data of PIN authentication. | | OnSetData(uint64_t scheduleId, uint64_t authSubType, <br>const std::vector<uint8_t> &data) | Called to return the subtype and anonymized data of PIN authentication. |
| Enroll(uint64_t scheduleId, const std::vector<uint8_t>& extraInfo,<br>const sptr<IExecutorCallback>& callbackObj) | Enrolls a PIN. | | Enroll(uint64_t scheduleId, const std::vector<uint8_t>& extraInfo,<br>const sptr<IExecutorCallback>& callbackObj) | Enrolls a PIN. |
| Authenticate(uint64_t scheduleId, uint64_t templateId, const std::vector<uint8_t>& extraInfo, const sptr<IExecutorCallback>& callbackObj) | Starts PIN authentication. | | Authenticate(uint64_t scheduleId, uint64_t templateId, const std::vector<uint8_t>& extraInfo, const sptr<IExecutorCallback>& callbackObj) | Starts PIN authentication. |
...@@ -93,7 +93,7 @@ The pin_auth driver provides basic PIN authentication capabilities for the UserI ...@@ -93,7 +93,7 @@ The pin_auth driver provides basic PIN authentication capabilities for the UserI
### How to Develop ### How to Develop
The following uses the RK3568 platform as an example to demonstrate how to develop the pin_auth driver. <br/>The directory structure is as follows: The following uses the RK3568 platform as an example to demonstrate how to develop the Pin_auth driver. <br/>The directory structure is as follows:
``` ```
// drivers/peripheral/pin_auth // drivers/peripheral/pin_auth
...@@ -104,13 +104,13 @@ The following uses the RK3568 platform as an example to demonstrate how to devel ...@@ -104,13 +104,13 @@ The following uses the RK3568 platform as an example to demonstrate how to devel
├── inc # Header files ├── inc # Header files
└── src └── src
├── executor_impl.cpp # Implementation of authentication and enrollment APIs ├── executor_impl.cpp # Implementation of authentication and enrollment APIs
── pin_auth_interface_driver.cpp # Pin_auth driver entry ── pin_auth_interface_driver.cpp # Pin_auth driver entry
└── pin_auth_interface_service.cpp # Implementation of the APIs for obtaining the executor list └── pin_auth_interface_service.cpp # Implementation of the APIs for obtaining the executor list
``` ```
The development procedure is as follows: The development procedure is as follows:
1. Develop the pin_auth driver based on the HDF. The **Bind()**, **Init()**, **Release()**, and **Dispatch()** functions are used. For details about the code, see [pin_auth_interface_driver.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/src/pin_auth_interface_driver.cpp). 1. Develop the Pin_auth driver based on the HDF. The **Bind()**, **Init()**, **Release()**, and **Dispatch()** functions are used. For details about the code, see [pin_auth_interface_driver.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/Pin_auth/hdi_service/src/pin_auth_interface_driver.cpp).
```c++ ```c++
// Create the PinAuthInterfaceService object by using the custom HdfPinAuthInterfaceHost object, which consists of the IoService object and HDI service. // Create the PinAuthInterfaceService object by using the custom HdfPinAuthInterfaceHost object, which consists of the IoService object and HDI service.
...@@ -156,7 +156,7 @@ The development procedure is as follows: ...@@ -156,7 +156,7 @@ The development procedure is as follows:
return HDF_SUCCESS; return HDF_SUCCESS;
} }
// Bind the service provided by the pin_auth driver to the HDF. // Bind the service provided by the Pin_auth driver to the HDF.
static int HdfPinAuthInterfaceDriverBind(struct HdfDeviceObject *deviceObject) static int HdfPinAuthInterfaceDriverBind(struct HdfDeviceObject *deviceObject)
{ {
IAM_LOGI("start"); IAM_LOGI("start");
...@@ -188,7 +188,7 @@ The development procedure is as follows: ...@@ -188,7 +188,7 @@ The development procedure is as follows:
return HDF_SUCCESS; return HDF_SUCCESS;
} }
// Release resources of the pin_auth driver. // Release resources of the Pin_auth driver.
static void HdfPinAuthInterfaceDriverRelease(struct HdfDeviceObject *deviceObject) static void HdfPinAuthInterfaceDriverRelease(struct HdfDeviceObject *deviceObject)
{ {
IAM_LOGI("start"); IAM_LOGI("start");
...@@ -340,7 +340,7 @@ The development procedure is as follows: ...@@ -340,7 +340,7 @@ The development procedure is as follows:
return HDF_SUCCESS; return HDF_SUCCESS;
} }
// After the executor is successfully registered, obtain the public key and template ID list from UserIAM and save the public key obtained. The executor compares its template ID list with the template ID list obtained and updates its template ID list. // After the executor is successfully registered, obtain the public key and template ID list from User_auth and save the public key obtained. The executor compares its template ID list with the template ID list obtained and updates its template ID list.
int32_t ExecutorImpl::OnRegisterFinish(const std::vector<uint64_t> &templateIdList, int32_t ExecutorImpl::OnRegisterFinish(const std::vector<uint64_t> &templateIdList,
const std::vector<uint8_t> &frameworkPublicKey, const std::vector<uint8_t> &extraInfo) const std::vector<uint8_t> &frameworkPublicKey, const std::vector<uint8_t> &extraInfo)
{ {
...@@ -526,9 +526,8 @@ The development procedure is as follows: ...@@ -526,9 +526,8 @@ The development procedure is as follows:
### Verification ### Verification
Verify whether PIN authentication can be successfully performed on the RK3568 platform as follows: Verify whether PIN authentication can be successfully performed on the RK3568 platform as follows:
1. Set a PIN. 1. Set a PIN.<br/>
Touch **Settings** > **Biometrics & passwords** > **Password**, and enter your password.
Touch **Settings** > **Biometrics & passwords** > **Password**, and enter your password.
2. Verify PIN authentication. 2. Verify PIN authentication.
...@@ -549,5 +548,3 @@ Verify whether PIN authentication can be successfully performed on the RK3568 pl ...@@ -549,5 +548,3 @@ Verify whether PIN authentication can be successfully performed on the RK3568 pl
1) Touch **Settings** > **Biometrics & passwords** > **Password**. 1) Touch **Settings** > **Biometrics & passwords** > **Password**.
2) Touch **Change screen lock password** and set the new password. 2) Touch **Change screen lock password** and set the new password.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册