“8226d44bee2ea0ac9c67af7f0e6dac90a87c47c3”上不存在“...inference/git@gitcode.net:s920243400/PaddleDetection.git”
提交 e31df1e3 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 4df77dcd
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
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 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.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -35,38 +35,20 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i ...@@ -35,38 +35,20 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.| | name | string | Yes| Name of the **Preferences** instance persistence file.|
| callback | AsyncCallback&lt;[Preferences](#preferences)&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;[Preferences](#preferences)&gt; | Yes| Callback used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
import data_preferences from '@ohos.data.preferences'
export default class MainAbility extends Ability {
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) { if (err) {
console.info("Failed to get the preferences") console.info("Failed to get the preferences")
return; return;
} }
preferences.put('startup', 'auto', function (err) { console.info("Got preferences successfully.")
if (err) { })
console.info("Failed to put the value of startup, err: " + err) ```
return
}
console.info("Put the value of startup successfully.")
preferences.flush(function (err) {
if (err) {
console.info("Failed to flush data to file, err: " + err)
return
}
console.info("Flushed data to file successfully.")
})
})
})
}
```
## data_preferences.getPreferences ## data_preferences.getPreferences
...@@ -80,7 +62,7 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i ...@@ -80,7 +62,7 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.| | name | string | Yes| Name of the **Preferences** instance persistence file.|
**Return value** **Return value**
...@@ -89,32 +71,14 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i ...@@ -89,32 +71,14 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i
| Promise&lt;[Preferences](#preferences)&gt; | Promise used to return the result.| | Promise&lt;[Preferences](#preferences)&gt; | Promise used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' let promise = data_preferences.getPreferences(this.context, 'mystore')
import data_preferences from '@ohos.data.preferences' promise.then((preferences) => {
export default class MainAbility extends Ability { console.info("Got preferences successfully.")
}).catch((err) => {
let promise = data_preferences.getPreferences(this.context, 'mystore')
promise.then((preferences) => {
preferences.put('startup', 'auto', function (err) {
if (err) {
console.info("Failed to put the value of startup, err: " + err)
return
}
console.info("Put the value of startup successfully.")
preferences.flush(function (err) {
if (err) {
console.info("Failed to flush data to file, err: " + err)
return
}
console.info("Flushed data to file successfully.")
})
})
}).catch((err) => {
console.info("Failed to get the preferences") console.info("Failed to get the preferences")
}) })
} ```
```
## data_preferences.deletePreferences ## data_preferences.deletePreferences
...@@ -129,25 +93,20 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance ...@@ -129,25 +93,20 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.| | name | string | Yes| Name of the **Preferences** instance persistence file.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' data_preferences.deletePreferences(this.context, 'mystore', function (err) {
import data_preferences from '@ohos.data.preferences'
export default class MainAbility extends Ability {
data_preferences.deletePreferences(this.context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to delete data, err: " + err) console.info("Failed to delete data, err: " + err)
return return
} }
console.info("Data deleted successfully.") console.info("Deleted preferences successfully.")
}) })
} ```
```
## data_preferences.deletePreferences ## data_preferences.deletePreferences
...@@ -162,7 +121,7 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance ...@@ -162,7 +121,7 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.| | name | string | Yes| Name of the **Preferences** instance persistence file.|
**Return value** **Return value**
...@@ -171,19 +130,14 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance ...@@ -171,19 +130,14 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' let promise = data_preferences.deletePreferences(this.context, 'mystore')
import data_preferences from '@ohos.data.preferences' promise.then(() => {
export default class MainAbility extends Ability { console.info("Deleted preferences successfully.")
}).catch((err) => {
let promise = data_preferences.deletePreferences(this.context, 'mystore') console.info("Failed to delete preferences, err: " + err)
promise.then(() => { })
console.info("Data deleted successfully.") ```
}).catch((err) => {
console.info("Failed to delete data, err: " + err)
})
}
```
## data_preferences.removePreferencesFromCache ## data_preferences.removePreferencesFromCache
...@@ -199,25 +153,20 @@ When a **Preferences** singleton instance is removed, this instance cannot be us ...@@ -199,25 +153,20 @@ When a **Preferences** singleton instance is removed, this instance cannot be us
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.| | name | string | Yes| Name of the **Preferences** instance persistence file.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) {
import data_preferences from '@ohos.data.preferences'
export default class MainAbility extends Ability {
data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to remove preferences from cache, err: " + err) console.info("Failed to remove preferences from cache, err: " + err)
return return
} }
console.info("Removed preferences from cache successfully.") console.info("Removed preferences from cache successfully.")
}) })
} ```
```
## data_preferences.removePreferencesFromCache ## data_preferences.removePreferencesFromCache
...@@ -230,10 +179,10 @@ When a **Preferences** singleton instance is removed, this instance cannot be us ...@@ -230,10 +179,10 @@ When a **Preferences** singleton instance is removed, this instance cannot be us
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.| | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.| | name | string | Yes| Name of the **Preferences** instance persistence file.|
**Return value** **Return value**
...@@ -242,19 +191,14 @@ When a **Preferences** singleton instance is removed, this instance cannot be us ...@@ -242,19 +191,14 @@ When a **Preferences** singleton instance is removed, this instance cannot be us
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' let promise = data_preferences.removePreferencesFromCache(this.context, 'mystore')
import data_preferences from '@ohos.data.preferences' promise.then(() => {
export default class MainAbility extends Ability {
let promise = data_preferences.removePreferencesFromCache(this.context, 'mystore')
promise.then(() => {
console.info("Removed preferences from cache successfully.") console.info("Removed preferences from cache successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Failed to remove preferences from cache, err: " + err) console.info("Failed to remove preferences from cache, err: " + err)
}) })
} ```
```
## Preferences ## Preferences
...@@ -278,26 +222,15 @@ Obtains the value of a key. If the value is null or a non-default value, the def ...@@ -278,26 +222,15 @@ Obtains the value of a key. If the value is null or a non-default value, the def
| callback | AsyncCallback&lt;ValueType&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;ValueType&gt; | Yes| Callback used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability'
import data_preferences from '@ohos.data.preferences'
export default class MainAbility extends Ability {
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) {
console.info("Failed to get the preferences, err: " + err)
return
}
preferences.get('startup', 'default', function(err, value) { preferences.get('startup', 'default', function(err, value) {
if (err) { if (err) {
console.info("Failed to get the value of startup, err: " + err) console.info("Failed to get the value of startup, err: " + err)
return return
} }
console.info("The value of startup is " + value) console.info("The value of startup is " + value)
}) })
}) ```
}
```
### get ### get
...@@ -320,24 +253,14 @@ Obtains the value of a key. If the value is null or a non-default value, the def ...@@ -320,24 +253,14 @@ Obtains the value of a key. If the value is null or a non-default value, the def
| Promise&lt;ValueType&gt; | Promise used to return the result.| | Promise&lt;ValueType&gt; | Promise used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' let promise = preferences.get('startup', 'default')
import data_preferences from '@ohos.data.preferences' promise.then((value) => {
export default class MainAbility extends Ability {
let promise = data_preferences.getPreferences(this.context, 'mystore')
promise.then((preferences) => {
let promiseGet = preferences.get('startup', 'default')
promiseGet.then((value) => {
console.info("The value of startup is " + value) console.info("The value of startup is " + value)
}).catch((err) => { }).catch((err) => {
console.info("Failed to get the value of startup, err: " + err) console.info("Failed to get the value of startup, err: " + err)
}) })
}).catch((err) => { ```
console.info("Failed to get the preferences, err: " + err)
})
}
```
### put ### put
...@@ -356,26 +279,15 @@ Puts a new value to this **Preferences** instance and its persistence file. This ...@@ -356,26 +279,15 @@ Puts a new value to this **Preferences** instance and its persistence file. This
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' preferences.put('startup', 'auto', function (err) {
import data_preferences from '@ohos.data.preferences'
export default class MainAbility extends Ability {
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) {
console.info("Failed to get the preferences, err: " + err)
return
}
preferences.put('startup', 'auto', function (err) {
if (err) { if (err) {
console.info("Failed to put the value of startup, err: " + err) console.info("Failed to put the value of startup, err: " + err)
return return
} }
console.info("Put the value of startup successfully.") console.info("Put the value of startup successfully.")
}) })
}) ```
}
```
### put ### put
...@@ -398,24 +310,14 @@ Puts a new value to this **Preferences** instance and its persistence file. This ...@@ -398,24 +310,14 @@ Puts a new value to this **Preferences** instance and its persistence file. This
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' let promise = preferences.put('startup', 'auto')
import data_preferences from '@ohos.data.preferences' promise.then(() => {
export default class MainAbility extends Ability {
let promise = data_preferences.getPreferences(this.context, 'mystore')
promise.then((preferences) => {
let promisePut = preferences.put('startup', 'auto')
promisePut.then(() => {
console.info("Put the value of startup successfully.") console.info("Put the value of startup successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Failed to put the value of startup, err: " + err) console.info("Failed to put the value of startup, err: " + err)
}) })
}).catch((err) => { ```
console.info("Failed to get the preferences, err: " + err)
})
}
```
### has ### has
...@@ -438,17 +340,8 @@ Checks whether this **Preferences** instance contains data with a given key. Thi ...@@ -438,17 +340,8 @@ Checks whether this **Preferences** instance contains data with a given key. Thi
| boolean | Returns **true** if the **Preferences** instance contains data with the specified key; returns **false** otherwise.| | boolean | Returns **true** if the **Preferences** instance contains data with the specified key; returns **false** otherwise.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' preferences.has('startup', function (err, isExist) {
import data_preferences from '@ohos.data.preferences'
export default class MainAbility extends Ability {
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) {
console.info("Failed to get the preferences, err: " + err)
return
}
preferences.has('startup', function (err, isExist) {
if (err) { if (err) {
console.info("Failed to check the key of startup, err: " + err) console.info("Failed to check the key of startup, err: " + err)
return return
...@@ -458,10 +351,8 @@ Checks whether this **Preferences** instance contains data with a given key. Thi ...@@ -458,10 +351,8 @@ Checks whether this **Preferences** instance contains data with a given key. Thi
} else { } else {
console.info("The key of startup is not contained.") console.info("The key of startup is not contained.")
} }
}) })
}) ```
}
```
### has ### has
...@@ -483,28 +374,18 @@ Checks whether this **Preferences** instance contains data with a given key. Thi ...@@ -483,28 +374,18 @@ Checks whether this **Preferences** instance contains data with a given key. Thi
| Promise&lt;boolean&gt; | Promise used to return the result.| | Promise&lt;boolean&gt; | Promise used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' let promise = preferences.has('startup')
import data_preferences from '@ohos.data.preferences' promise.then((isExist) => {
export default class MainAbility extends Ability {
let promise = data_preferences.getPreferences(this.context, 'mystore')
promise.then((preferences) => {
let promiseHas = preferences.has('startup')
promiseHas.then((isExist) => {
if (isExist) { if (isExist) {
console.info("The key of startup is contained.") console.info("The key of startup is contained.")
} else { } else {
console.info("The key of startup is not contained.") console.info("The key of startup is not contained.")
} }
}).catch((err) => { }).catch((err) => {
console.info("Check the key of startup failed, err: " + err) console.info("Check the key of startup failed, err: " + err)
}) })
}).catch((err) => { ```
console.info("Failed to get the preferences, err: " + err)
})
}
```
### delete ### delete
...@@ -522,26 +403,15 @@ Deletes a KV pair of the specified key from this **Preferences** instance. This ...@@ -522,26 +403,15 @@ Deletes a KV pair of the specified key from this **Preferences** instance. This
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' preferences.delete('startup', function (err) {
import data_preferences from '@ohos.data.preferences'
export default class MainAbility extends Ability {
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) {
console.info("Failed to get the preferences, err: " + err)
return
}
preferences.delete('startup', function (err) {
if (err) { if (err) {
console.info("Failed to delete startup key, err: " + err) console.info("Failed to delete startup key, err: " + err)
return return
} }
console.info("Deleted startup key successfully.") console.info("Deleted startup key successfully.")
}) })
}) ```
}
```
### delete ### delete
...@@ -563,24 +433,14 @@ Deletes a KV pair of the specified key from this **Preferences** instance. This ...@@ -563,24 +433,14 @@ Deletes a KV pair of the specified key from this **Preferences** instance. This
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' let promise = preferences.delete('startup')
import data_preferences from '@ohos.data.preferences' promise.then(() => {
export default class MainAbility extends Ability {
let promise = data_preferences.getPreferences(this.context, 'mystore')
promise.then((preferences) => {
let promiseDelete = preferences.delete('startup')
promiseDelete.then(() => {
console.info("Deleted startup key successfully.") console.info("Deleted startup key successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Failed to delete startup key, err: " + err) console.info("Failed to delete startup key, err: " + err)
}) })
}).catch((err) => { ```
console.info("Failed to get the preferences, err: " + err)
})
}
```
### flush ### flush
...@@ -597,26 +457,15 @@ Saves the modification to this **Preferences** instance and synchronizes the mod ...@@ -597,26 +457,15 @@ Saves the modification to this **Preferences** instance and synchronizes the mod
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' preferences.flush(function (err) {
import data_preferences from '@ohos.data.preferences'
export default class MainAbility extends Ability {
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) {
console.info("Failed to get the preferences, err: " + err)
return
}
preferences.flush(function (err) {
if (err) { if (err) {
console.info("Failed to flush data to file, err: " + err) console.info("Failed to flush data to file, err: " + err)
return return
} }
console.info("Flushed data to file successfully.") console.info("Flushed data to file successfully.")
}) })
}) ```
}
```
### flush ### flush
...@@ -633,24 +482,14 @@ Saves the modification to this **Preferences** instance and synchronizes the mod ...@@ -633,24 +482,14 @@ Saves the modification to this **Preferences** instance and synchronizes the mod
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' let promise = preferences.flush()
import data_preferences from '@ohos.data.preferences' promise.then(() => {
export default class MainAbility extends Ability {
let promise = data_preferences.getPreferences(this.context, 'mystore')
promise.then((preferences) => {
let promiseFlush = preferences.flush()
promiseFlush.then(() => {
console.info("Flushed data to file successfully.") console.info("Flushed data to file successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Failed to flush data to file, err: " + err) console.info("Failed to flush data to file, err: " + err)
}) })
}).catch((err) => { ```
console.info("Failed to get the preferences, err: " + err)
})
}
```
### clear ### clear
...@@ -661,32 +500,21 @@ Clears data of this **Preferences** instance. This API uses an asynchronous call ...@@ -661,32 +500,21 @@ Clears data of this **Preferences** instance. This API uses an asynchronous call
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters** Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' preferences.clear(function (err) {
import data_preferences from '@ohos.data.preferences'
export default class MainAbility extends Ability {
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) {
console.info("Failed to get the preferences, err: " + err)
return
}
preferences.clear(function (err) {
if (err) { if (err) {
console.info("Failed to clear data, err: " + err) console.info("Failed to clear data, err: " + err)
return return
} }
console.info("Cleared to file successfully.") console.info("Cleared to file successfully.")
}) })
}) ```
}
```
### clear ### clear
...@@ -703,24 +531,14 @@ Clears data of this **Preferences** instance. This API uses a promise to return ...@@ -703,24 +531,14 @@ Clears data of this **Preferences** instance. This API uses a promise to return
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' let promise = preferences.clear()
import data_preferences from '@ohos.data.preferences' promise.then(() => {
export default class MainAbility extends Ability {
let promise = data_preferences.getPreferences(this.context, 'mystore')
promise.then((preferences) => {
let promiseClear = preferences.clear()
promiseClear.then(() => {
console.info("Cleared to file successfully.") console.info("Cleared to file successfully.")
}).catch((err) => { }).catch((err) => {
console.info("Failed to clear data, err: " + err) console.info("Failed to clear data, err: " + err)
}) })
}).catch((err) => { ```
console.info("Failed to get the preferences, err: " + err)
})
}
```
### on('change') ### on('change')
...@@ -738,26 +556,21 @@ Subscribes to data changes. When the value of the subscribed key changes, a call ...@@ -738,26 +556,21 @@ Subscribes to data changes. When the value of the subscribed key changes, a call
| callback | Callback&lt;{ key : string }&gt; | Callback used to return data changes.| | callback | Callback&lt;{ key : string }&gt; | Callback used to return data changes.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' var observer = function (key) {
import data_preferences from '@ohos.data.preferences'
export default class MainAbility extends Ability {
var observer = function (key) {
console.info("The key of " + key + " changed.") console.info("The key of " + key + " changed.")
} }
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) { ...
console.info("Failed to get the preferences, err: " + err)
return preferences.on('change', observer)
} preferences.put('startup', 'auto', function (err) {
preferences.on('change', observer)
preferences.put('startup', 'auto', function (err) {
if (err) { if (err) {
console.info("Failed to put the value of startup, err: " + err) console.info("Failed to put the value of startup, err: " + err)
return return
} }
console.info("Put the value of startup successfully.") console.info("Put the value of startup successfully.")
preferences.flush(function (err) { preferences.flush(function (err) {
if (err) { if (err) {
console.info("Failed to flush data to file, err: " + err) console.info("Failed to flush data to file, err: " + err)
...@@ -765,10 +578,8 @@ Subscribes to data changes. When the value of the subscribed key changes, a call ...@@ -765,10 +578,8 @@ Subscribes to data changes. When the value of the subscribed key changes, a call
} }
console.info("Flushed data to file successfully.") // The observer will be called. console.info("Flushed data to file successfully.") // The observer will be called.
}) })
}) })
}) ```
}
```
### off('change') ### off('change')
...@@ -786,37 +597,31 @@ Unsubscribes from data changes. ...@@ -786,37 +597,31 @@ Unsubscribes from data changes.
| callback | Callback&lt;{ key : string }&gt; | Callback used to return data changes.| | callback | Callback&lt;{ key : string }&gt; | Callback used to return data changes.|
**Example** **Example**
```ts ```ts
import Ability from '@ohos.application.Ability' var observer = function (key) {
import data_preferences from '@ohos.data.preferences'
export default class MainAbility extends Ability {
var observer = function (key) {
console.info("The key of " + key + " changed.") console.info("The key of " + key + " changed.")
} }
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) { ...
console.info("Failed to get the preferences, err: " + err)
return preferences.on('change', observer)
} preferences.put('startup', 'auto', function (err) {
preferences.on('change', observer)
preferences.put('startup', 'auto', function (err) {
if (err) { if (err) {
console.info("Failed to put the value of startup, err: " + err) console.info("Failed to put the value of startup, err: " + err)
return return
} }
console.info("Put the value of startup successfully.") console.info("Put the value of startup successfully.")
preferences.flush(function (err) { preferences.flush(function (err) {
if (err) { if (err) {
console.info("Failed to flush data to file, err: " + err) console.info("Failed to flush data to file, err: " + err)
return return
} }
console.info("Flushed to file successfully.") // observer will be called. console.info("Flushed data to file successfully.") // The observer will be called.
preferences.off('change', observer) preferences.off('change', observer)
}) })
}) })
}) ```
}
```
## ValueType ## ValueType
......
...@@ -4,16 +4,16 @@ ...@@ -4,16 +4,16 @@
### Function ### Function
Personal Identification Number (PIN) authentication provides user authentication capabilities and applies to 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, 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 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.
**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, deletion, and performing authentication. 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.
- Executor - Executor
...@@ -37,7 +37,7 @@ The identity authentication consists of UserIAM and basic authentication service ...@@ -37,7 +37,7 @@ The identity authentication consists of UserIAM and basic authentication service
- UserIAM public key & executor public key - UserIAM 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 need to 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 UserIAM and basic authentication services. Public keys must be exchanged when the executor provided by a basic authentication service interworks with UserIAM.
- The executor uses the UserIAM public key to verify the scheduling instruction. - The executor uses the UserIAM public key to verify the scheduling instruction.
...@@ -50,7 +50,7 @@ The identity authentication consists of UserIAM and basic authentication service ...@@ -50,7 +50,7 @@ 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, compares its template ID list with the template ID list obtained, and updates its template ID list accordingly. 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.
### Working Principles ### Working Principles
...@@ -65,7 +65,7 @@ PIN authentication must be implemented in a TEE, and the confidential informatio ...@@ -65,7 +65,7 @@ PIN authentication must be implemented in a TEE, and the confidential informatio
## Development Guidelines ## Development Guidelines
### When to Use ### When to Use
The pin_auth driver provides basic capabilities of PIN authentication for the UserIAM and pin_auth service to ensure successful PIN authentication. The pin_auth driver provides basic PIN authentication capabilities for the UserIAM and pin_auth service to ensure successful PIN authentication.
### Available APIs ### Available APIs
...@@ -499,7 +499,7 @@ The development procedure is as follows: ...@@ -499,7 +499,7 @@ The development procedure is as follows:
return HDF_SUCCESS; return HDF_SUCCESS;
} }
// Cancel the operation of the specified scheduleId. // Cancel the operation based on the specified scheduleId.
int32_t ExecutorImpl::Cancel(uint64_t scheduleId) int32_t ExecutorImpl::Cancel(uint64_t scheduleId)
{ {
IAM_LOGI("start"); IAM_LOGI("start");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册