diff --git a/en/application-dev/database/database-distributedobject-guidelines.md b/en/application-dev/database/database-distributedobject-guidelines.md
index 08b72e45cbd9c1f505f99be567e45296fbce8c52..4ff96ed5e1b1427d87a35043d2ee53cb686c3698 100644
--- a/en/application-dev/database/database-distributedobject-guidelines.md
+++ b/en/application-dev/database/database-distributedobject-guidelines.md
@@ -2,7 +2,7 @@
## When to Use
-The distributed data objects allow data across devices to be processed like local variables by shielding complex data interaction between devices. For the devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other devices. The devices can listen for the data changes and online and offline states of other devices. The distributed data objects support basic data types, such as number, string, and Boolean, as well as complex data types, such as array and nested basic types.
+The distributed data objects allow data across devices to be processed like local variables by shielding complex data interaction between devices. For the devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other devices. The devices can listen for the data changes and online and offline status of other devices. The distributed data objects support basic data types, such as number, string, and Boolean, as well as complex data types, such as array and nested basic types.
## Available APIs
@@ -15,7 +15,7 @@ Call **createDistributedObject()** to create a distributed data object instance.
**Table 1** API for creating a distributed data object instance
| Package| API| Description|
| -------- | -------- | -------- |
-| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.
- **source**: attributes of the **distributedObject** set.
- **DistributedObject**: returns the distributed object created.|
+| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.
- **source**: attributes of the **distributedObject** set.
- **DistributedObject**: returns the distributed object created.|
### Generating a Session ID
@@ -28,12 +28,12 @@ Call **genSessionId()** to generate a session ID randomly. The generated session
### Setting a SessionID for Distributed Data Objects
-Call setSessionId() to set the session ID for a distributed data object. The session ID is a unique identifier for one collaboration across devices. The distributed data objects to be synchronized must be associated with the same session ID.
+Call **setSessionId()** to set a session ID for a distributed data object. The session ID is a unique identifier for one collaboration across devices. The distributed data objects to be synchronized must be associated with the same session ID.
**Table 3** API for setting a session ID
| Class| API| Description|
| -------- | -------- | -------- |
-| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.
**sessionId**: ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
+| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.
**sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
### Observing Data Changes
@@ -43,7 +43,7 @@ Call **on()** to subscribe to data changes of a distributed data object. When th
| Class| API| Description|
| -------- | -------- | -------- |
| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | Subscribes to data changes.|
-| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes. Callback used to return changes of the distributed object. If this parameter is not specified, all callbacks related to data changes will be unregistered.|
+| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes.
**Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.|
### Observing Online or Offline Status
@@ -90,10 +90,10 @@ The following example shows how to implement a distributed data object synchroni
var remote_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true,
parent:undefined, list:undefined});
remote_object.setSessionId(sessionId);
- // After obtaining that the device status goes online, the remote object synchronizes data. That is, name changes to jack and age to 18.
+ // After learning that the device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18.
```
-4. Observe the data changes of the distributed data object. Subscribe to data changes of the remote end. When the data is the peer end changes, a callback will be called to return the data changes.
+4. Observe the data changes of the distributed data object. You can subscribe to data changes of the remote object. When the data in the remote object changes, a callback will be called to return the data changes.
The sample code is as follows:
@@ -108,8 +108,8 @@ The following example shows how to implement a distributed data object synchroni
}
}
- // To refresh the page in changeCallback, correctly set this.changeCallback.bind(this) in
- changeCallback.
+ // To refresh the page in changeCallback, correctly bind (this) to the changeCallback.
+ local_object.on("change", this.changeCallback.bind(this));
```
5. Modify object attributes. The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types).
@@ -123,7 +123,7 @@ The following example shows how to implement a distributed data object synchroni
local_object.list = [{mother:"jack mom"}, {father:"jack Dad"}];
```
- > ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**
+ > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified. Example:
```js
// Supported modification.
@@ -142,7 +142,7 @@ The following example shows how to implement a distributed data object synchroni
The sample code is as follows:
```js
- // Unsubscribe from changeCallback.
+ // Unsubscribe from the specified data change callback.
local_object.off("change", changeCallback);
// Unsubscribe from all data change callbacks.
local_object.off("change");
@@ -156,16 +156,16 @@ The following example shows how to implement a distributed data object synchroni
local_object.on("status", this.statusCallback);
```
-9. Unsubscribe from the status changes of the distributed data object. You can specify the callback to unsubscribe from. If you do not specify the callback, all status change callbacks will be unsubscribe from.
+9. Unsubscribe from the status changes of the distributed data object. You can specify the callback to unsubscribe from. If you do not specify the callback, this API unsubscribes from all callbacks of this distributed data object.
The sample code is as follows:
```js
- // Unsubscribe from the online status change callback.
+ // Unsubscribe from the specified status change callback.
local_object.off("status", statusCallback);
- // Unsubscribe from all online status change callbacks.
+ // Unsubscribe from all status change callbacks.
local_object.off("status");
```
-10. Remove a distributed data object from the synchronization network. After the distributed data object is removed from the network, the data changes on the local end will not be synchronized to the remote end.
+10. Remove a distributed data object from the synchronization network. Data changes on the local object will not be synchronized to the removed distributed data object.
The sample code is as follows:
```js
@@ -173,10 +173,10 @@ The following example shows how to implement a distributed data object synchroni
```
## Development Example
-The following example is provided for you to better understand the development of distributed data object:
+The following example is provided for you to better understand the development of distributed data objects:
- [Distributed Notepad](https://gitee.com/openharmony/distributeddatamgr_objectstore/tree/master/samples/distributedNotepad)
-When an event occurs on a device, such as a note is added, the tile or content of a note is changed, and the event list is cleared, the change will be synchronized to other devices in the trusted network by the Notepad app.
+When an event of the Notepad app occurs on a device, such as a note is added, the tile or content of a note is changed, or the event list is cleared, the change will be synchronized to other devices in the trusted network.
diff --git a/en/application-dev/reference/apis/js-apis-data-distributedobject.md b/en/application-dev/reference/apis/js-apis-data-distributedobject.md
index 6670e2eefaea1bd07d85083bf5436833613f998e..5ac7b6707c3afd30d7ccc6ae966fdf99439bd697 100644
--- a/en/application-dev/reference/apis/js-apis-data-distributedobject.md
+++ b/en/application-dev/reference/apis/js-apis-data-distributedobject.md
@@ -1,6 +1,6 @@
# Distributed Data Object
-> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -26,7 +26,7 @@ Creates a distributed data object.
| -------- | -------- | -------- | -------- |
| source | object | Yes| Attribute of the distributed data object to create.|
-**Return Value**
+**Return value**
| Type| Description|
| -------- | -------- |
| [DistributedObject](#distributedobject) | Distributed data object created.|
@@ -34,7 +34,7 @@ Creates a distributed data object.
**Example**
```js
import distributedObject from '@ohos.data.distributedDataObject'
- // Create a distributedObject instance. The attribute type of the object can be string, number, boolean, or Object.
+ // Create a distributed data object, which contains attributes of four types, namely, string, number, boolean, and object.
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}});
```
@@ -48,7 +48,7 @@ Creates a random session ID.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
-**Return Value**
+**Return value**
| Type| Description|
| -------- | -------- |
| string | Session ID created.|
@@ -62,7 +62,7 @@ Creates a random session ID.
## DistributedObject
-Represents a **distributedObject** instance.
+Represents a distributed data object.
### setSessionId
@@ -78,7 +78,7 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
| -------- | -------- | -------- | -------- |
| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
-**Return Value**
+**Return value**
| Type| Description|
| -------- | -------- |
@@ -101,15 +101,15 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void
-Subscribes to the data changes of this distributed data object.
+Subscribes to the changes of this distributed data object.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data change events.|
- | callback | Callback<{ sessionId: string, fields: Array<string> }> | Yes| Callback used to return the changes of the distributed data object.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the attributes of the distributed data object changed.|
+ | type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.|
+ | callback | Callback<{ sessionId: string, fields: Array<string> }> | Yes| Callback used to return the changes of the distributed data object.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the changed attributes of the distributed data object.|
**Example**
```js
@@ -130,15 +130,15 @@ Subscribes to the data changes of this distributed data object.
off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void
-Unsubscribes from the data changes of this distributed data object.
+Unsubscribes from the changes of this distributed data object.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data change events.|
- | callback | Callback<{ sessionId: string, fields: Array<string> }> | No| Callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the attributes of the distributed data object changed.|
+ | type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.|
+ | callback | Callback<{ sessionId: string, fields: Array<string> }> | No| Callback used to return the changes of the distributed data object. If this parameter is not specified, this API unsubscribes from all callbacks for data changes of this distributed data object.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the changed attributes of the distributed data object.|
**Example**
@@ -149,11 +149,11 @@ Unsubscribes from the data changes of this distributed data object.
g_object.on("change", function (sessionId, changeData) {
console.info("change" + sessionId);
});
- // Unsubscribe from the data change callback for the specified distributed data object.
+ // Unsubscribe from the specified data change callback for the distributed data object.
g_object.off("change", function (sessionId, changeData) {
console.info("change" + sessionId);
});
- // Unsubscribe from all data change callbacks.
+ // Unsubscribe from all data change callbacks for the distributed data object.
g_object.off("change");
```
@@ -161,15 +161,15 @@ Unsubscribes from the data changes of this distributed data object.
on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' | 'offline' }>): void
-Subscribes to the status changes (online or offline) of this distributed data object.
+Subscribes to the status change (online or offline) of this distributed data object.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | type | string | Yes| Event type to subscribe to. The value is "status", which indicates the status (online or offline) change events.|
- | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the online or offline status.
**sessionId** indicates the session ID of the distributed data object.
**networkId** indicates the network ID of the device.
**status** indicates the status, which can be online or offline.|
+ | type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the change in the status (online or offline) of the distributed data object.|
+ | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the status change.
**sessionId** indicates the session ID of the distributed data object.
**networkId** indicates the network ID of the device.
**status** indicates the status, which can be online or offline.|
**Example**
```js
@@ -186,15 +186,15 @@ Subscribes to the status changes (online or offline) of this distributed data ob
off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' | 'offline' }>): void
-Unsubscribes from the status (online or offline) changes of the distributed data object.
+Unsubscribes from the status change (online or offline) of this distributed data object.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | type | string | Yes| Event type to subscribe to. The value is "status", which indicates the status (online or offline) change events.|
- | callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback used to return the status changes. If this parameter is not specified, all the status change callbacks will be unregistered.
**sessionId** indicates the session ID of the distributed data object.
**deviceId** indicates the device ID of the distributed data object.
**status** indicates the status, which can be online or offline.|
+ | type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the change in the status (online or offline) of the distributed data object.|
+ | callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback used to return the status change. If this parameter is not specified, this API unsubscribes from all callbacks of this distributed data object.
**sessionId** indicates the session ID of the distributed data object.
**deviceId** indicates the device ID of the distributed data object.
**status** indicates the status, which can be online or offline.|
**Example**
@@ -203,10 +203,10 @@ Unsubscribes from the status (online or offline) changes of the distributed data
g_object.on("status", function (sessionId, networkId, status) {
this.response += "status changed " + sessionId + " " + status + " " + networkId;
});
- // Unsubscribe from the status change callback for the specified distributed data object.
+ // Unsubscribe from the specified status change callback for the distributed data object.
g_object.off("status", function (sessionId, networkId, status) {
this.response += "status changed " + sessionId + " " + status + " " + networkId;
});
- // Unsubscribe from all status change callbacks.
+ // Unsubscribe from all status change callbacks for the distributed data object.
g_object.off("status");
```
diff --git a/en/application-dev/reference/apis/js-apis-data-preferences.md b/en/application-dev/reference/apis/js-apis-data-preferences.md
index 791908e6c9a8e8509f364c587fa132958e475c31..afd07e6d85cd00e521fb230415e9f32cdd5d1fe3 100644
--- a/en/application-dev/reference/apis/js-apis-data-preferences.md
+++ b/en/application-dev/reference/apis/js-apis-data-preferences.md
@@ -1,6 +1,6 @@
# Preferences
-Preferences provide capabilities for processing key-value (KV) data for applications and supports lightweight data persistence, modification, and query. Data is stored 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**
@@ -27,7 +27,7 @@ import data_preferences from '@ohos.data.preferences';
getPreferences(context: Context, name: string, callback: AsyncCallback<Preferences>): void
-Reads a preference persistence file and loads data to the **Preferences** instance for data operations. This API uses an asynchronous callback to return the result.
+Reads a **Preferences** persistence file and loads data to the **Preferences** instance for data operations. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
@@ -35,9 +35,9 @@ Reads a preference persistence file and loads data to the **Preferences** instan
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.|
+ | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.|
- | callback | AsyncCallback<[Preferences](#preferences)> | Yes| Callback used to return the execution result.|
+ | callback | AsyncCallback<[Preferences](#preferences)> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -73,20 +73,20 @@ Reads a preference persistence file and loads data to the **Preferences** instan
getPreferences(context: Context, name: string): Promise<Preferences>
-Reads a preference persistence file and loads data to the **Preferences** instance for data operations. This API uses a promise to return the result.
+Reads a **Preferences** persistence file and loads data to the **Preferences** instance for data operations. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.|
+ | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.|
**Return value**
| Type| Description|
| -------- | -------- |
- | Promise<[Preferences](#preferences)> | Promise used to return the execution result.|
+ | Promise<[Preferences](#preferences)> | Promise used to return the result.|
**Example**
```ts
@@ -122,16 +122,16 @@ Reads a preference persistence file and loads data to the **Preferences** instan
deletePreferences(context: Context, name: string, callback: AsyncCallback<void>): void
Deletes a **Preferences** singleton instance, the persistence file and backup file, and corrupted files from the memory.
-Once a preference persistence file is deleted, the **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the execution result.
+Once a **Preferences** persistence file is deleted, the **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.|
+ | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.|
- | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -144,7 +144,7 @@ Once a preference persistence file is deleted, the **Preferences** instance cann
console.info("Failed to delete data, err: " + err)
return
}
- console.info("Deleted data successfully.")
+ console.info("Data deleted successfully.")
})
}
```
@@ -155,20 +155,20 @@ Once a preference persistence file is deleted, the **Preferences** instance cann
deletePreferences(context: Context, name: string): Promise<void>
Deletes a **Preferences** singleton instance, the persistence file and backup file, and corrupted files from the memory.
-Once a preference persistence file is deleted, the **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the execution result.
+Once a **Preferences** persistence file is deleted, the **Preferences** instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.|
+ | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.|
**Return value**
| Type| Description|
| -------- | -------- |
- | Promise<void> | Promise used to return the execution result.|
+ | Promise<void> | Promise used to return the result.|
**Example**
```ts
@@ -178,7 +178,7 @@ Once a preference persistence file is deleted, the **Preferences** instance cann
let promise = data_preferences.deletePreferences(this.context, 'mystore')
promise.then(() => {
- console.info("Deleted data successfully.")
+ console.info("Data deleted successfully.")
}).catch((err) => {
console.info("Failed to delete data, err: " + err)
})
@@ -192,16 +192,16 @@ removePreferencesFromCache(context: Context, name: string, callback: AsyncCallba
Removes a **Preferences** singleton instance from the memory.
-When a **Preferences** singleton instance is removed, this instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the execution result.
+When a **Preferences** singleton instance is removed, this instance cannot be used for data operations. Otherwise, data inconsistency will occur. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.|
+ | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.|
- | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -233,13 +233,13 @@ When a **Preferences** singleton instance is removed, this instance cannot be us
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | context | [Context](js-apis-Context.md) | Yes| Context of the app or functionality.|
+ | context | [Context](js-apis-Context.md) | Yes| Context of the application or functionality.|
| name | string | Yes| Name of the **Preferences** instance persistence file.|
**Return value**
| Type| Description|
| -------- | -------- |
- | Promise<void> | Promise used to return the execution result.|
+ | Promise<void> | Promise used to return the result.|
**Example**
```ts
@@ -275,7 +275,7 @@ Obtains the value of a key. If the value is null or a non-default value, the def
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to obtain. It cannot be empty.|
| defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.|
- | callback | AsyncCallback<ValueType> | Yes| Callback used to return the execution result.|
+ | callback | AsyncCallback<ValueType> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -285,12 +285,12 @@ Obtains the value of a key. If the value is null or a non-default value, the def
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) {
- console.info("Get the preferences failed, err: " + err)
+ console.info("Failed to get the preferences, err: " + err)
return
}
preferences.get('startup', 'default', function(err, value) {
if (err) {
- console.info("Get the value of startup failed, err: " + err)
+ console.info("Failed to get the value of startup, err: " + err)
return
}
console.info("The value of startup is " + value)
@@ -308,7 +308,7 @@ Obtains the value of a key. If the value is null or a non-default value, the def
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
-- **Parameters**
+**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to obtain. It cannot be empty.|
@@ -317,7 +317,7 @@ Obtains the value of a key. If the value is null or a non-default value, the def
**Return value**
| Type| Description|
| -------- | -------- |
- | Promise<ValueType> | Promise used to return the execution result.|
+ | Promise<ValueType> | Promise used to return the result.|
**Example**
```ts
@@ -334,7 +334,7 @@ Obtains the value of a key. If the value is null or a non-default value, the def
console.info("Failed to get the value of startup, err: " + err)
})
}).catch((err) => {
- console.info("Get the preferences failed, err: " + err)
+ console.info("Failed to get the preferences, err: " + err)
})
}
```
@@ -344,7 +344,7 @@ Obtains the value of a key. If the value is null or a non-default value, the def
put(key: string, value: ValueType, callback: AsyncCallback<void>): void
-Obtains a **Preferences** instance, writes data to the **Preferences** instance, and saves the data to the file using **flush()** or **flushSync()**. This API uses an asynchronous callback to return the execution result.
+Puts a new value to this **Preferences** instance and its persistence file. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
@@ -353,7 +353,7 @@ Obtains a **Preferences** instance, writes data to the **Preferences** instance,
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data. It cannot be empty.|
| value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.|
- | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -382,7 +382,7 @@ Obtains a **Preferences** instance, writes data to the **Preferences** instance,
put(key: string, value: ValueType): Promise<void>
-Obtains a **Preferences** instance, writes data to the **Preferences** instance, and saves the data to the file using **flush()** or **flushSync()**. This API uses a promise to return the execution result.
+Puts a new value to this **Preferences** instance and its persistence file. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
@@ -395,7 +395,7 @@ Obtains a **Preferences** instance, writes data to the **Preferences** instance,
**Return value**
| Type| Description|
| -------- | -------- |
- | Promise<void> | Promise used to return the execution result.|
+ | Promise<void> | Promise used to return the result.|
**Example**
```ts
@@ -412,7 +412,7 @@ Obtains a **Preferences** instance, writes data to the **Preferences** instance,
console.info("Failed to put the value of startup, err: " + err)
})
}).catch((err) => {
- console.info("Get the preferences failed, err: " + err)
+ console.info("Failed to get the preferences, err: " + err)
})
}
```
@@ -422,7 +422,7 @@ Obtains a **Preferences** instance, writes data to the **Preferences** instance,
has(key: string, callback: AsyncCallback<boolean>): boolean
-Checks whether the **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.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
@@ -430,7 +430,7 @@ Checks whether the **Preferences** instance contains data with a given key. This
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to check. It cannot be empty.|
- | callback | AsyncCallback<boolean> | Yes| Callback used to return the execution result.|
+ | callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
**Return value**
| Type| Description|
@@ -468,7 +468,7 @@ Checks whether the **Preferences** instance contains data with a given key. This
has(key: string): Promise<boolean>
-Checks whether the **Preferences** instance contains data with a given key. This API uses a promise to return the result.
+Checks whether this **Preferences** instance contains data with a given key. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
@@ -480,7 +480,7 @@ Checks whether the **Preferences** instance contains data with a given key. This
**Return value**
| Type| Description|
| -------- | -------- |
- | Promise<boolean> | Promise used to return the execution result.|
+ | Promise<boolean> | Promise used to return the result.|
**Example**
```ts
@@ -501,7 +501,7 @@ Checks whether the **Preferences** instance contains data with a given key. This
console.info("Check the key of startup failed, err: " + err)
})
}).catch((err) => {
- console.info("Get the preferences failed, err: " + err)
+ console.info("Failed to get the preferences, err: " + err)
})
}
```
@@ -511,7 +511,7 @@ Checks whether the **Preferences** instance contains data with a given key. This
delete(key: string, callback: AsyncCallback<void>): void
-Deletes the KV pair of the specified key from this **Preferences** instance. This API uses an asynchronous callback to return the result.
+Deletes a KV pair of the specified key from this **Preferences** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
@@ -519,7 +519,7 @@ Deletes the KV pair of the specified key from this **Preferences** instance. Thi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the KV pair to delete. It cannot be empty.|
- | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -548,7 +548,7 @@ Deletes the KV pair of the specified key from this **Preferences** instance. Thi
delete(key: string): Promise<void>
-Deletes the KV pair of the specified key from this **Preferences** instance. This API uses a promise to return the result.
+Deletes a KV pair of the specified key from this **Preferences** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
@@ -560,7 +560,7 @@ Deletes the KV pair of the specified key from this **Preferences** instance. Thi
**Return value**
| Type| Description|
| -------- | -------- |
- | Promise<void> | Promise used to return the execution result.|
+ | Promise<void> | Promise used to return the result.|
**Example**
```ts
@@ -587,14 +587,14 @@ Deletes the KV pair of the specified key from this **Preferences** instance. Thi
flush(callback: AsyncCallback<void>): void
-Saves the modification to this **Preferences** instance and synchronizes the modification to the preference persistence file. This API uses an asynchronous callback to return the result.
+Saves the modification to this **Preferences** instance and synchronizes the modification to the **Preferences** persistence file. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -623,14 +623,14 @@ Saves the modification to this **Preferences** instance and synchronizes the mod
flush(): Promise<void>
-Saves the modification to this **Preferences** instance and synchronizes the modification to the preference persistence file. This API uses a promise to return the result.
+Saves the modification to this **Preferences** instance and synchronizes the modification to the **Preferences** persistence file. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Return value**
| Type| Description|
| -------- | -------- |
- | Promise<void> | Promise used to return the execution result.|
+ | Promise<void> | Promise used to return the result.|
**Example**
```ts
@@ -664,7 +664,7 @@ Clears data of this **Preferences** instance. This API uses an asynchronous call
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -700,7 +700,7 @@ Clears data of this **Preferences** instance. This API uses a promise to return
**Return value**
| Type| Description|
| -------- | -------- |
- | Promise<void> | Promise used to return the execution result.|
+ | Promise<void> | Promise used to return the result.|
**Example**
```ts
diff --git a/en/application-dev/security/huks-guidelines.md b/en/application-dev/security/huks-guidelines.md
index 9d1d0fde76338b73eeb1bce98e704faf398a0dd0..4b89db682161071a11136e4510fac134159e8b66 100644
--- a/en/application-dev/security/huks-guidelines.md
+++ b/en/application-dev/security/huks-guidelines.md
@@ -2,19 +2,19 @@
## When to Use
- Openharmony Universal KeyStore (HUKS) provides KeyStore (KS) capabilities for applications, including key management and key cryptography operations. HUKS also provides APIs for applications to import or generate keys.
+ OpenHarmony Universal KeyStore (HUKS) provides KeyStore (KS) capabilities for applications, including key management and key cryptography operations. HUKS also provides APIs for applications to import or generate keys.
## Available APIs
| API | Description |
| ------------------------------------------------------------ | ---------------- |
-| function generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | Generates a private key. This method uses an asynchronous callback to return the result. |
-| function generateKey(keyAlias: string, options: HuksOptions) : Promise; | Generates a private key. This method uses a promise to return the result. |
+| function generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | Generates a key. This method uses an asynchronous callback to return the result. |
+| function generateKey(keyAlias: string, options: HuksOptions) : Promise; | Generates a key. This method uses a promise to return the result. |
| function exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | Exports the public key. This method uses an asynchronous callback to return the result. |
| function exportKey(keyAlias: string, options: HuksOptions) : Promise; | Exports the public key. This method uses a promise to return the result. |
-| function isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | Check whether a key exists. This method uses an asynchronous callback to return the result.|
-| function isKeyExist(keyAlias: string, options: HuksOptions) : Promise; | Check whether a key exists. This method uses a promise to return the result.|
+| function isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | Checks whether a key exists. This method uses an asynchronous callback to return the result. |
+| function isKeyExist(keyAlias: string, options: HuksOptions) : Promise; | Checks whether a key exists. This method uses a promise to return the result. |
| function deleteKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; | Deletes a key. This method uses an asynchronous callback to return the result. |
| function deleteKey(keyAlias: string, options: HuksOptions) : Promise; | Deletes a key. This method uses a promise to return the result. |
@@ -26,7 +26,7 @@
import huks from '@ohos.security.huks'
```
-2. Call **generateKey()** to generate a private key.
+2. Call **generateKey()** to generate a key.
**keyAlias** indicates the alias of the key generated. **options** indicates the parameters used for generating the key. Set **options** based on the actual situation.
@@ -59,7 +59,7 @@
3. Call **Init()** to initialize the key.
- **Alias** indicates the alias of the key to initialize, and **options** indicates the parameters used for initializing the key.
+ **Alias** indicates the alias of the key to initialize, and **options** indicates the parameters used for initializing the key. Set **options** based on the actual situation.
The value returned indicates whether the **Init** operation is successful.
@@ -92,7 +92,7 @@
4. Call **update()** to update the key.
- **handle** indicates the session ID for updating the key. **options** indicates the parameters used for updating the key.
+ **handle** indicates the session ID for updating the key. **options** indicates the parameters used for updating the key. Set **options** based on the actual situation.
The value returned indicates whether the **Update** operation is successful.
@@ -118,7 +118,7 @@
5. Call **finish()** to complete the operation.
- **handle** indicates the session ID of the **Finish** operation. **options** indicates the parameters used for this operation.
+ **handle** indicates the session ID of the **Finish** operation. **options** indicates the parameters used for this operation. Set **options** based on the actual situation.
The value returned indicates whether the **Finish** operation is successful.
diff --git a/en/device-dev/driver/driver-hdf-servicemanage.md b/en/device-dev/driver/driver-hdf-servicemanage.md
index f9445db98f0b376532383df3a6fa182b5b44ff41..e2d273ca2bc999b6b8e3e84aa57887f942f77393 100644
--- a/en/device-dev/driver/driver-hdf-servicemanage.md
+++ b/en/device-dev/driver/driver-hdf-servicemanage.md
@@ -1,10 +1,10 @@
# Driver Service Management
-Driver services are objects of capabilities provided by HDF driver devices to external systems and are managed by the HDF in a unified manner. Driver service management involves providing and obtaining driver services.
+Driver services are objects of capabilities provided by HDF driver devices to external systems and are managed by the HDF in a unified manner. Driver service management involves publishing and obtaining driver services.
-The HDF uses the **policy** field in the configuration file to define policies for drivers to provide services externally. The values this field are as follows:
+The HDF uses the **policy** field in the configuration file to define policies for drivers to publish services externally. The values this field are as follows:
@@ -12,13 +12,13 @@ The HDF uses the **policy** field in the configuration file to define policies f
typedef enum {
/* The driver does not provide services. */
SERVICE_POLICY_NONE = 0,
- /* The driver provides services only for kernel-mode applications. */
+ /* The driver publishes services only for kernel-mode processes. */
SERVICE_POLICY_PUBLIC = 1,
- /* The driver provides services for both kernel- and user-mode applications. */
+ /* The driver publishes services for both kernel- and user-mode processes. */
SERVICE_POLICY_CAPACITY = 2,
- /** The driver services are not provided externally but can be subscribed to. */
+ /** The driver services are not published externally but can be subscribed to. */
SERVICE_POLICY_FRIENDLY = 3,
- /* The driver private services cannot be provided externally or subscribed to. */
+ /* The driver private services cannot be published externally or subscribed to. */
SERVICE_POLICY_PRIVATE = 4,
/** Invalid service policy. */
SERVICE_POLICY_INVALID
diff --git a/en/device-dev/kernel/kernel-standard-mm-eswap.md b/en/device-dev/kernel/kernel-standard-mm-eswap.md
index f623c62ab1685c4926b1dca19493de62ae07ee49..0a4f464ec0d123c289f5c0614d9575cdf77a18f4 100644
--- a/en/device-dev/kernel/kernel-standard-mm-eswap.md
+++ b/en/device-dev/kernel/kernel-standard-mm-eswap.md
@@ -11,7 +11,7 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
### Enabling ESwap
1. Enable related configuration items and dependencies.
- To enable ESwap, you need to enable the corresponding configuration items and dependencies during kernel compilation. The configuration items related to ESwap are as follows:
+ To enable ESwap, you must enable the corresponding configuration items and dependencies during kernel compilation. The configuration items related to ESwap are as follows:
```
CONFIG_HYPERHOLD=y
@@ -41,13 +41,13 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
```Bash
// Run the dd command to create the hpdisk file for ESwap. In this example, the file size is 512 MB. Set the file size based on service requirements.
dd if=/dev/random of=/data/hpdisk bs=4096 count=131072
- // Associate the hpdisk file created with the ESwap device.
+ // Associate the hpdisk file with the ESwap device.
losetup /dev/block/loop6 hpdisk
```
3. Configure ESwap.
- Bind the device created in 2 as the ESwap device.
+ Bind the device created in step 2 as the ESwap device.
```Bash
echo /dev/block/loop6 > /proc/sys/kernel/hyperhold/device
@@ -56,11 +56,11 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
By default, ESwap encrypts the data swapped out. If the ESwap device created in step 2 supports inline encryption, you can disable the ESwap software encryption function.
```Bash
- // Check whether hardware-based encryption is supported and enabled. If not, do not perform this operation.
+ // Check whether hardware-based encryption is supported and enabled. If yes, disable software encryption. Otherwise, do not perform this operation.
echo 0 > /proc/sys/kernel/hyperhold/soft_crypt
```
- > ![icon-caution.gif](../public_sys-resources/icon-caution.gif)**CAUTION**
+ > ![icon-caution.gif](../public_sys-resources/icon-caution.gif) **CAUTION**
> For security purposes, all swapped content must be encrypted. If the ESwap device created does not support inline encryption or the inline encryption macro is not enabled during compilation, ESwap cannot be enabled after software encryption is disabled.
4. Enable ESwap.
@@ -72,8 +72,8 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
```
-> ![icon-note.gif](../public_sys-resources/icon-note.gif)**NOTE**
-> Enable ESwap before zram is enabled. If ESwap is not used, you can enable zram only. If a device does not have the storage device for swap-out or have the corresponding storage partition created, you can enable ZRAM to reclaim memory using **zswapd**.
+> ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**
+> Enable ESwap before zram is enabled. If ESwap is not used, you can enable zram only. If a device does not have the storage device for swap-out or have the corresponding storage partition created, you can enable zram to reclaim memory using **zswapd**.
### Enabling zram
@@ -88,7 +88,7 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
echo 512M > /sys/block/zram0/disksize
```
- > ![icon-note.gif](../public_sys-resources/icon-note.gif)**NOTE**
+ > ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**
> The parameters and functions of **/sys/block/zram0/group** are as follows:
>
> - **disable**: disables the function.
@@ -115,11 +115,11 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
echo force_disable > /proc/sys/kernel/hyperhold/enable
```
- > ![icon-note.gif](../public_sys-resources/icon-note.gif)**NOTE**
+ > ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**
> The difference of the two commands is as follows:
>
- > - **disable**: If there is no data in the ESwap partition, disable ESwap. Otherwise, changes ESwap to read-only mode.
- > - **force_disable**: If there is no data in the ESwap partition, disable ESwap. Otherwise, changes ESwap to read-only mode and disable ESwap until all data in the ESWAP partition is read.
+ > - **disable**: If there is no data in the ESwap partition, disable ESwap. Otherwise, changes ESwap to **readonly** mode.
+ > - **force_disable**: If there is no data in the ESwap partition, disable ESwap. Otherwise, changes ESwap to **readonly** mode and disable ESwap until all data in the ESWAP partition is read.
2. Disable zram and zram group.
@@ -143,7 +143,7 @@ ESwap provides APIs to control swap-in and swap-out policies and record the curr
| | [stat](#stat) | Checks the real-time status of ESwap.|
| | [zswapd_vmstat_show](#zswapd_vmstat_show) | Records events during the zswapd running.|
-> ![icon-caution.gif](../public_sys-resources/icon-caution.gif)**CAUTION**
+> ![icon-caution.gif](../public_sys-resources/icon-caution.gif) **CAUTION**
> Only **avail_buffers** proactively wakes up zswapd because the buffer waterline is adjusted. Other control APIs do not proactively wake up zswapd, but their configuration takes effect only after zswapd is woken up.
The APIs are described as follows:
diff --git a/en/readme/netwowk-management.md b/en/readme/netwowk-management.md
index 13dc0951936c47a6fd440f46b06536c0e996f5f7..8186e61d5c9519abc1c832c90e71b0fe4ab27aa8 100644
--- a/en/readme/netwowk-management.md
+++ b/en/readme/netwowk-management.md
@@ -1,7 +1,7 @@
-# Network Management
+# Network Management
-## Introduction
+## Introduction
As a mandatory component for device networking, the network management subsystem manages different types of network connections in a unified manner and provides network protocol stack capabilities. An application can call APIs to obtain connection information of a data network, query and subscribe to connection status, and transfer data by using the network protocol stack.
@@ -14,7 +14,7 @@ The network management subsystem consists of the following components:
![](figures/en_architecture-of-netmanager-subsystem.png)
-## Directory Structure
+## Directory Structure
```
foundation/communication/
@@ -22,21 +22,21 @@ foundation/communication/
└── netstack # Network protocol stacks
```
-## Usage
+## Usage
-### Receiving Network Status Change Notifications
+### Receiving Network Status Change Notifications
1. Import the **connection** namespace from **@ohos.net.connection.d.ts**.
-2. Call **createNetConnection()** to create a **NetConnection object**. You can specify the network capability, network type, and timeout interval (optional).
+2. Call **createNetConnection()** to create a **NetConnection** object. You can specify the network capability, network type, and timeout interval.
3. Call the **on()** method of the object to subscribe to concerned events by specifying **type** and **callback**.
-4. Call the **register()** method of the object to subscribe to status change notifications of the specified network.
+4. Call the **register()** method of the object to subscribe to status changes of the specified network.
5. When the network is available, the callback will be invoked to return the **netAvailable** event.
-6. Call the **unregister()** method of the object to unsubscribe from the notifications if required.
+6. Call the **unregister()** method of the object to unsubscribe from the status changes if required.
```
// Import the package name.
@@ -66,11 +66,11 @@ foundation/communication/
```
-### Sending a Network Request
+### Sending a Network Request
1. Import the **http** namespace from **@ohos.net.http.d.ts**.
2. Call the **createHttp** method to create an **HttpRequest** object.
-3. Call the **on()** method of the object to subscribe to the HTTP response header. This method returns a response earlier than the request. You can subscribe to HTTP Response Header events based on service requirements.
+3. Call the **on()** method of the object to subscribe to the HTTP response header. This method returns a response earlier than the request. You can subscribe to HTTP response header events based on service requirements.
4. Call the **request()** method of the object with the URL and optional parameters of the HTTP request to initiate a network request.
5. Parse the returned result based on service requirements.
6. Call the **destroy()** method to destroy the request.
@@ -81,7 +81,7 @@ import http from '@ohos.net.http';
// Each httpRequest corresponds to an HttpRequestTask object and cannot be reused.
let httpRequest = http.createHttp();
-// Subscribe to the HTTP response header, which is returned earlier than httpRequest. You can subscribe to HTTP Response Header events based on service requirements.
+// Subscribe to the HTTP response header, which is returned earlier than httpRequest. You can subscribe to HTTP response header events based on service requirements.
httpRequest.on('headersReceive', (data) => {
console.info('header: ' + data.header);
});
@@ -118,10 +118,10 @@ httpRequest.request(
```
-## Repositories Involved
+## Repositories Involved
**Network Management Subsystem**
-[communication_netmanager_base](https://gitee.com/openharmony/communication_netmanager_base/blob/master/README_zh.md)
+[communication_netmanager_base](https://gitee.com/openharmony/communication_netmanager_base)
-[communication_netstack](https://gitee.com/openharmony/communication_netstack/blob/master/README_zh.md)
+[communication_netstack](https://gitee.com/openharmony/communication_netstack)