提交 2ac2108e 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 0729632e
# DataAbilityPredicates # DataAbilityPredicates
> **NOTE**<br/> > **NOTE**<br/>
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -17,7 +18,7 @@ import dataAbility from '@ohos.data.dataAbility'; ...@@ -17,7 +18,7 @@ import dataAbility from '@ohos.data.dataAbility';
createRdbPredicates(name: string, dataAbilityPredicates: DataAbilityPredicates): rdb.RdbPredicates createRdbPredicates(name: string, dataAbilityPredicates: DataAbilityPredicates): rdb.RdbPredicates
Creates an **RdbPredicates** object based on a **DataAabilityPredicates** object. Creates an **RdbPredicates** object from a **DataAbilityPredicates** object.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
...@@ -69,8 +70,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu ...@@ -69,8 +70,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.equalTo("NAME", "lisi")
predicates.equalTo("NAME", "lisi")
``` ```
...@@ -97,8 +97,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu ...@@ -97,8 +97,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.notEqualTo("NAME", "lisi")
predicates.notEqualTo("NAME", "lisi")
``` ```
...@@ -119,8 +118,7 @@ Adds a left parenthesis to this **DataAbilityPredicates**. ...@@ -119,8 +118,7 @@ Adds a left parenthesis to this **DataAbilityPredicates**.
**Example** **Example**
```js ```js
let predicates = new dataAbilitylity.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.equalTo("NAME", "lisi")
predicates.equalTo("NAME", "lisi")
.beginWrap() .beginWrap()
.equalTo("AGE", 18) .equalTo("AGE", 18)
.or() .or()
...@@ -146,8 +144,7 @@ Adds a right parenthesis to this **DataAbilityPredicates**. ...@@ -146,8 +144,7 @@ Adds a right parenthesis to this **DataAbilityPredicates**.
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.equalTo("NAME", "lisi")
predicates.equalTo("NAME", "lisi")
.beginWrap() .beginWrap()
.equalTo("AGE", 18) .equalTo("AGE", 18)
.or() .or()
...@@ -173,8 +170,7 @@ Adds the OR condition to this **DataAbilityPredicates**. ...@@ -173,8 +170,7 @@ Adds the OR condition to this **DataAbilityPredicates**.
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.equalTo("NAME", "Lisa")
predicates.equalTo("NAME", "Lisa")
.or() .or()
.equalTo("NAME", "Rose") .equalTo("NAME", "Rose")
``` ```
...@@ -197,8 +193,7 @@ Adds the AND condition to this **DataAbilityPredicates**. ...@@ -197,8 +193,7 @@ Adds the AND condition to this **DataAbilityPredicates**.
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.equalTo("NAME", "Lisa")
predicates.equalTo("NAME", "Lisa")
.and() .and()
.equalTo("SALARY", 200.5) .equalTo("SALARY", 200.5)
``` ```
...@@ -227,8 +222,7 @@ Sets a **DataAbilityPredicates** object to match a string containing the specifi ...@@ -227,8 +222,7 @@ Sets a **DataAbilityPredicates** object to match a string containing the specifi
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.contains("NAME", "os")
predicates.contains("NAME", "os")
``` ```
...@@ -255,8 +249,7 @@ Sets a **DataAbilityPredicates** object to match a string that starts with the s ...@@ -255,8 +249,7 @@ Sets a **DataAbilityPredicates** object to match a string that starts with the s
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.beginsWith("NAME", "os")
predicates.beginsWith("NAME", "os")
``` ```
...@@ -283,8 +276,7 @@ Sets a **DataAbilityPredicates** object to match a string that ends with the spe ...@@ -283,8 +276,7 @@ Sets a **DataAbilityPredicates** object to match a string that ends with the spe
**Example** **Example**
``` ```
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.endsWith("NAME", "se")
predicates.endsWith("NAME", "se")
``` ```
...@@ -310,8 +302,7 @@ Sets a **DataAbilityPredicates** object to match the field whose value is null. ...@@ -310,8 +302,7 @@ Sets a **DataAbilityPredicates** object to match the field whose value is null.
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.isNull("NAME")
predicates.isNull("NAME")
``` ```
...@@ -337,8 +328,7 @@ Sets a **DataAbilityPredicates** object to match the field whose value is not nu ...@@ -337,8 +328,7 @@ Sets a **DataAbilityPredicates** object to match the field whose value is not nu
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.isNotNull("NAME")
predicates.isNotNull("NAME")
``` ```
...@@ -365,8 +355,7 @@ Sets a **DataAbilityPredicates** object to match a string that is similar to the ...@@ -365,8 +355,7 @@ Sets a **DataAbilityPredicates** object to match a string that is similar to the
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.like("NAME", "%os%")
predicates.like("NAME", "%os%")
``` ```
...@@ -393,8 +382,7 @@ Sets a **DataAbilityPredicates** object to match the specified string. ...@@ -393,8 +382,7 @@ Sets a **DataAbilityPredicates** object to match the specified string.
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.glob("NAME", "?h*g")
predicates.glob("NAME", "?h*g")
``` ```
...@@ -422,8 +410,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu ...@@ -422,8 +410,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.between("AGE", 10, 50)
predicates.between("AGE", 10, 50)
``` ```
...@@ -451,8 +438,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu ...@@ -451,8 +438,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.notBetween("AGE", 10, 50)
predicates.notBetween("AGE", 10, 50)
``` ```
...@@ -479,8 +465,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu ...@@ -479,8 +465,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.greaterThan("AGE", 18)
predicates.greaterThan("AGE", 18)
``` ```
...@@ -507,8 +492,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu ...@@ -507,8 +492,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.lessThan("AGE", 20)
predicates.lessThan("AGE", 20)
``` ```
...@@ -535,8 +519,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu ...@@ -535,8 +519,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.greaterThanOrEqualTo("AGE", 18)
predicates.greaterThanOrEqualTo("AGE", 18)
``` ```
...@@ -563,8 +546,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu ...@@ -563,8 +546,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.lessThanOrEqualTo("AGE", 20)
predicates.lessThanOrEqualTo("AGE", 20)
``` ```
...@@ -590,8 +572,7 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i ...@@ -590,8 +572,7 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.orderByAsc("NAME")
predicates.orderByAsc("NAME")
``` ```
...@@ -617,8 +598,7 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i ...@@ -617,8 +598,7 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.orderByDesc("AGE")
predicates.orderByDesc("AGE")
``` ```
...@@ -639,8 +619,7 @@ Sets a **DataAbilityPredicates** object to filter out duplicate records. ...@@ -639,8 +619,7 @@ Sets a **DataAbilityPredicates** object to filter out duplicate records.
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.equalTo("NAME", "Rose").distinct("NAME")
predicates.equalTo("NAME", "Rose").distinct("NAME")
let promiseDistinct = rdbStore.query(predicates, ["NAME"]) let promiseDistinct = rdbStore.query(predicates, ["NAME"])
promiseDistinct.then((resultSet) => { promiseDistinct.then((resultSet) => {
console.log("distinct") console.log("distinct")
...@@ -672,8 +651,7 @@ Set a **DataAbilityPredicates** object to specify the maximum number of records. ...@@ -672,8 +651,7 @@ Set a **DataAbilityPredicates** object to specify the maximum number of records.
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.equalTo("NAME", "Rose").limitAs(3)
predicates.equalTo("NAME", "Rose").limitAs(3)
``` ```
...@@ -699,8 +677,7 @@ Sets a **DataAbilityPredicates** object to specify the start position of the ret ...@@ -699,8 +677,7 @@ Sets a **DataAbilityPredicates** object to specify the start position of the ret
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.equalTo("NAME", "Rose").offsetAs(3)
predicates.equalTo("NAME", "Rose").offsetAs(3)
``` ```
...@@ -726,8 +703,7 @@ Sets a **DataAbilityPredicates** object to group rows that have the same value i ...@@ -726,8 +703,7 @@ Sets a **DataAbilityPredicates** object to group rows that have the same value i
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.groupBy(["AGE", "NAME"])
predicates.groupBy(["AGE", "NAME"])
``` ```
### indexedBy ### indexedBy
...@@ -751,8 +727,7 @@ Sets a **DataAbilityPredicates** object to specify the index column. ...@@ -751,8 +727,7 @@ Sets a **DataAbilityPredicates** object to specify the index column.
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.indexedBy("SALARY_INDEX")
predicates.indexedBy("SALARY_INDEX")
``` ```
...@@ -762,7 +737,7 @@ Sets a **DataAbilityPredicates** object to specify the index column. ...@@ -762,7 +737,7 @@ Sets a **DataAbilityPredicates** object to specify the index column.
in(field: string, value: Array&lt;ValueType&gt;): DataAbilityPredicates in(field: string, value: Array&lt;ValueType&gt;): DataAbilityPredicates
Sets a **DataAbilityPredicates** object to match the field with data type Array\<ValueType> and value within the specified range. Sets a **DataAbilityPredicates** object to match the field with data type Array<ValueType> and value within the specified range.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
...@@ -780,8 +755,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array\ ...@@ -780,8 +755,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array\
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.in("AGE", [18, 20])
predicates.in("AGE", [18, 20])
``` ```
...@@ -791,7 +765,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array\ ...@@ -791,7 +765,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array\
notIn(field: string, value: Array&lt;ValueType&gt;): DataAbilityPredicates notIn(field: string, value: Array&lt;ValueType&gt;): DataAbilityPredicates
Sets a **DataAbilityPredicates** object to match the field with data type Array\<ValueType> and value out of the specified range. Sets a **DataAbilityPredicates** object to match the field with data type Array<ValueType> and value out of the specified range.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
...@@ -809,8 +783,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array\ ...@@ -809,8 +783,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array\
**Example** **Example**
```js ```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE") dataAbilityPredicates.notIn("NAME", ["Lisa", "Rose"])
predicates.notIn("NAME", ["Lisa", "Rose"])
``` ```
## ValueType ## ValueType
......
...@@ -31,7 +31,7 @@ Creates a distributed data object. ...@@ -31,7 +31,7 @@ Creates a distributed data object.
**Example** **Example**
```js ```js
import distributedObject from '@ohos.data.distributedDataObject' import distributedObject from '@ohos.data.distributedDataObject';
// Create a distributed data object, which contains attributes of four types, namely, string, number, boolean, and 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, var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}}); parent:{mother:"jack mom",father:"jack Dad"}});
...@@ -53,7 +53,7 @@ Creates a random session ID. ...@@ -53,7 +53,7 @@ Creates a random session ID.
**Example** **Example**
```js ```js
import distributedObject from '@ohos.data.distributedDataObject' import distributedObject from '@ohos.data.distributedDataObject';
var sessionId = distributedObject.genSessionId(); var sessionId = distributedObject.genSessionId();
``` ```
...@@ -85,7 +85,7 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo ...@@ -85,7 +85,7 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
**Example** **Example**
```js ```js
import distributedObject from '@ohos.data.distributedDataObject' import distributedObject from '@ohos.data.distributedDataObject';
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}}); parent:{mother:"jack mom",father:"jack Dad"}});
// Add g_object to the distributed network. // Add g_object to the distributed network.
...@@ -111,7 +111,7 @@ Subscribes to the changes of this distributed data object. ...@@ -111,7 +111,7 @@ Subscribes to the changes of this distributed data object.
**Example** **Example**
```js ```js
import distributedObject from '@ohos.data.distributedDataObject' import distributedObject from '@ohos.data.distributedDataObject';
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}}); parent:{mother:"jack mom",father:"jack Dad"}});
g_object.on("change", function (sessionId, changeData) { g_object.on("change", function (sessionId, changeData) {
...@@ -136,22 +136,22 @@ Unsubscribes from the changes of this distributed data object. ...@@ -136,22 +136,22 @@ Unsubscribes from the changes of this distributed data object.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.| | type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | 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.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.| | callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback to be unregistered. If this parameter is not specified, all data change callbacks of the object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example** **Example**
```js ```js
import distributedObject from '@ohos.data.distributedDataObject' import distributedObject from '@ohos.data.distributedDataObject';
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}}); parent:{mother:"jack mom",father:"jack Dad"}});
g_object.on("change", function (sessionId, changeData) { g_object.on("change", function (sessionId, changeData) {
console.info("change" + sessionId); console.info("change" + sessionId);
}); });
// Unsubscribe from the specified data change callback for the distributed data object. // Unregister the specified data change callback for the distributed data object.
g_object.off("change", function (sessionId, changeData) { g_object.off("change", function (sessionId, changeData) {
console.info("change" + sessionId); console.info("change" + sessionId);
}); });
// Unsubscribe from all data change callbacks for the distributed data object. // Unregister all data change callbacks for the distributed data object.
g_object.off("change"); g_object.off("change");
``` ```
...@@ -171,10 +171,10 @@ Subscribes to the status change (online or offline) of this distributed data obj ...@@ -171,10 +171,10 @@ Subscribes to the status change (online or offline) of this distributed data obj
**Example** **Example**
```js ```js
import distributedObject from '@ohos.data.distributedDataObject' import distributedObject from '@ohos.data.distributedDataObject';
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}}); parent:{mother:"jack mom",father:"jack Dad"}});
g_object.on("status", function (sessionId, networkid, status) { g_object.on("status", function (sessionId, networkId, status) {
this.response += "status changed " + sessionId + " " + status + " " + networkId; this.response += "status changed " + sessionId + " " + status + " " + networkId;
}); });
``` ```
...@@ -197,7 +197,7 @@ Unsubscribes from the status change (online or offline) of this distributed data ...@@ -197,7 +197,7 @@ Unsubscribes from the status change (online or offline) of this distributed data
**Example** **Example**
```js ```js
import distributedObject from '@ohos.data.distributedDataObject' import distributedObject from '@ohos.data.distributedDataObject';
g_object.on("status", function (sessionId, networkId, status) { g_object.on("status", function (sessionId, networkId, status) {
this.response += "status changed " + sessionId + " " + status + " " + networkId; this.response += "status changed " + sessionId + " " + status + " " + networkId;
}); });
......
...@@ -43,7 +43,7 @@ Declare the permissions required by the app one by one in the **config.json** fi ...@@ -43,7 +43,7 @@ Declare the permissions required by the app one by one in the **config.json** fi
```json ```json
{ {
"module" : { "module" : {
"requesetPermissions":[ "requestPermissions":[
{ {
"name" : "ohos.permission.PERMISSION1", "name" : "ohos.permission.PERMISSION1",
"reason": "$string:reason", "reason": "$string:reason",
...@@ -141,4 +141,4 @@ The procedure is as follows: ...@@ -141,4 +141,4 @@ The procedure is as follows:
``` ```
> **NOTE**<br> > **NOTE**<br>
> For details about how to use **requestPermissionsFromUser**, see [API Reference](../reference/apis/js-apis-ability-context.md#abilitycontextrequestpermissionsfromuser). > For details about how to use **requestPermissionsFromUser**, see [API Reference](../reference/apis/js-apis-ability-context.md).
...@@ -81,7 +81,8 @@ The usage of hapsigner varies depending on whether an application signing certif ...@@ -81,7 +81,8 @@ The usage of hapsigner varies depending on whether an application signing certif
-version # Display the tool version information. -version # Display the tool version information.
3. Generate a key pair.
3.Generate a key pair.
generate-keypair: Generate a key pair. generate-keypair: Generate a key pair.
├── -keyAlias # Key alias. It is mandatory. ├── -keyAlias # Key alias. It is mandatory.
...@@ -91,7 +92,7 @@ The usage of hapsigner varies depending on whether an application signing certif ...@@ -91,7 +92,7 @@ The usage of hapsigner varies depending on whether an application signing certif
├── -keystoreFile # KS file, in JKS or P12 format. It is mandatory. ├── -keystoreFile # KS file, in JKS or P12 format. It is mandatory.
├── -keystorePwd # KS password. It is optional. ├── -keystorePwd # KS password. It is optional.
4. Generate a CSR. 4.Generate a CSR.
generate-csr: Generate a CSR. generate-csr: Generate a CSR.
├── -keyAlias # Key alias. It is mandatory. ├── -keyAlias # Key alias. It is mandatory.
...@@ -102,7 +103,7 @@ The usage of hapsigner varies depending on whether an application signing certif ...@@ -102,7 +103,7 @@ The usage of hapsigner varies depending on whether an application signing certif
├── -keystorePwd # KS password. It is optional. ├── -keystorePwd # KS password. It is optional.
├── -outFile # CSR to generate. It is optional. If you do not specify this parameter, the CSR is output to the console. ├── -outFile # CSR to generate. It is optional. If you do not specify this parameter, the CSR is output to the console.
5. Generate a root CA or intermediate CA certificate. 5.Generate a root CA or intermediate CA certificate.
generate-ca: Generate a root CA or intermediate CA certificate. If the key does not exist, generate a key together with the certificate. generate-ca: Generate a root CA or intermediate CA certificate. If the key does not exist, generate a key together with the certificate.
├── -keyAlias # Key alias. It is mandatory. ├── -keyAlias # Key alias. It is mandatory.
...@@ -122,7 +123,7 @@ The usage of hapsigner varies depending on whether an application signing certif ...@@ -122,7 +123,7 @@ The usage of hapsigner varies depending on whether an application signing certif
├── -issuerKeystorePwd # KS password of the issuer. It is optional. ├── -issuerKeystorePwd # KS password of the issuer. It is optional.
├── -outFile # File to generate. It is optional. The file is output to the console if this parameter is not specified. ├── -outFile # File to generate. It is optional. The file is output to the console if this parameter is not specified.
6. Generate an application debug or release certificate. 6.Generate an application debug or release certificate.
generate-app-cert: Generate an application debug or release certificate. generate-app-cert: Generate an application debug or release certificate.
├── -keyAlias # Key alias. It is mandatory. ├── -keyAlias # Key alias. It is mandatory.
...@@ -142,7 +143,7 @@ The usage of hapsigner varies depending on whether an application signing certif ...@@ -142,7 +143,7 @@ The usage of hapsigner varies depending on whether an application signing certif
├── -subCaCertFile # Intermediate CA certificate, which is mandatory when outForm is certChain. ├── -subCaCertFile # Intermediate CA certificate, which is mandatory when outForm is certChain.
├── -outFile # Certificate file (certificate or certificate chain) to generate. It is optional. The file is output to the console if this parameter is not specified. ├── -outFile # Certificate file (certificate or certificate chain) to generate. It is optional. The file is output to the console if this parameter is not specified.
7. Generate a profile debug or release certificate. 7.Generate a profile debug or release certificate.
generate-profile-cert: Generate a profile debug or release certificate. generate-profile-cert: Generate a profile debug or release certificate.
├── -keyAlias # Key alias. It is mandatory. ├── -keyAlias # Key alias. It is mandatory.
...@@ -162,7 +163,7 @@ The usage of hapsigner varies depending on whether an application signing certif ...@@ -162,7 +163,7 @@ The usage of hapsigner varies depending on whether an application signing certif
├── -subCaCertFile # Intermediate CA certificate, which is mandatory when outForm is certChain. ├── -subCaCertFile # Intermediate CA certificate, which is mandatory when outForm is certChain.
├── -outFile # Certificate file (certificate or certificate chain) to generate. It is optional. The file is output to the console if this parameter is not specified. ├── -outFile # Certificate file (certificate or certificate chain) to generate. It is optional. The file is output to the console if this parameter is not specified.
8. Generate a common certificate, which can be used to generate a custom certificate. 8.Generate a common certificate, which can be used to generate a custom certificate.
generate-cert: Generate a common certificate, which can be used to generate a custom certificate. generate-cert: Generate a common certificate, which can be used to generate a custom certificate.
├── -keyAlias # Key alias. It is mandatory. ├── -keyAlias # Key alias. It is mandatory.
...@@ -190,9 +191,9 @@ The usage of hapsigner varies depending on whether an application signing certif ...@@ -190,9 +191,9 @@ The usage of hapsigner varies depending on whether an application signing certif
├── -keystorePwd # KS password. It is optional. ├── -keystorePwd # KS password. It is optional.
├── -outFile # Certificate file to generate. It is optional. The file is output to the console if this parameter is not specified. ├── -outFile # Certificate file to generate. It is optional. The file is output to the console if this parameter is not specified.
9. Sign a provisioning profile. 9.Sign a profile.
sign-profile: Sign a provisioning profile. sign-profile: Sign a profile.
├── -mode # Signing mode, which can be localSign or remoteSign. It is mandatory. ├── -mode # Signing mode, which can be localSign or remoteSign. It is mandatory.
├── -keyAlias # Key alias. It is mandatory. ├── -keyAlias # Key alias. It is mandatory.
├── -keyPwd # Key password. It is optional. ├── -keyPwd # Key password. It is optional.
...@@ -203,13 +204,13 @@ The usage of hapsigner varies depending on whether an application signing certif ...@@ -203,13 +204,13 @@ The usage of hapsigner varies depending on whether an application signing certif
├── -keystorePwd # KS password. It is optional. ├── -keystorePwd # KS password. It is optional.
├── -outFile # Signed provisioning profile to generate, in p7b format. It is mandatory. ├── -outFile # Signed provisioning profile to generate, in p7b format. It is mandatory.
10. Verify the provisioning profile signature. 10.Verify the profile signature.
verify-profile: Verify the provisioning profile signature. verify-profile: Verify the profile signature.
├── -inFile # Signed provisioning profile, in p7b format. It is mandatory. ├── -inFile # Signed provisioning profile, in p7b format. It is mandatory.
├── -outFile # Verification result file (including the verification result and profile content), in json format. It is optional. The file is output to the console if this parameter is not specified. ├── -outFile # Verification result file (including the verification result and profile content), in json format. It is optional. The file is output to the console if this parameter is not specified.
11. Sign a HAP. 11.Sign a HAP.
sign-app: Sign a HAP. sign-app: Sign a HAP.
├── -mode # Signing mode, which can be localSign, remoteSign, or remoteResign. It is mandatory. ├── -mode # Signing mode, which can be localSign, remoteSign, or remoteResign. It is mandatory.
...@@ -217,7 +218,7 @@ The usage of hapsigner varies depending on whether an application signing certif ...@@ -217,7 +218,7 @@ The usage of hapsigner varies depending on whether an application signing certif
├── -keyPwd # Key password. It is optional. ├── -keyPwd # Key password. It is optional.
├── -appCertFile # Application signing certificate (certificate chain, in the end-entity certificate, intermediate CA certificate, and root certificate order). It is mandatory. ├── -appCertFile # Application signing certificate (certificate chain, in the end-entity certificate, intermediate CA certificate, and root certificate order). It is mandatory.
├── -profileFile # Singed provisioning profile, in p7b format. It is mandatory. ├── -profileFile # Singed provisioning profile, in p7b format. It is mandatory.
├── -profileSigned # Whether the profile is signed. The value 1 means signed, and value 0 means unsigned. The default value is 1. It is optional. ├── -profileSigned # Whether the profile is signed. The value 1 means signed, and value 0 means unsigned. The default value is 1. This parameter is optional.
├── -inForm # Raw file, in .zip (default) or .bin format. It is optional. ├── -inForm # Raw file, in .zip (default) or .bin format. It is optional.
├── -inFile # Raw application package, in HAP or .bin format. It is mandatory. ├── -inFile # Raw application package, in HAP or .bin format. It is mandatory.
├── -signAlg # Signature algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory. ├── -signAlg # Signature algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory.
...@@ -225,14 +226,13 @@ The usage of hapsigner varies depending on whether an application signing certif ...@@ -225,14 +226,13 @@ The usage of hapsigner varies depending on whether an application signing certif
├── -keystorePwd # KS password. It is optional. ├── -keystorePwd # KS password. It is optional.
├── -outFile # Signed HAP file to generate. It is mandatory. ├── -outFile # Signed HAP file to generate. It is mandatory.
12. Verify the HAP signature. 12.Verify the HAP signature.
verify-app: Verify the HAP signature. verify-app: Verify the HAP signature.
├── -inFile # Signed application file, in HAP or bin format. It is mandatory. ├── -inFile # Signed application file, in HAP or bin format. It is mandatory.
├── -outCertchain # Signed certificate chain file. It is mandatory. ├── -outCertchain # Signed certificate chain file. It is mandatory.
├── -outProfile # Profile of the application. It is mandatory. ├── -outProfile # Profile of the application. It is mandatory.
### Signing Procedure ### Signing Procedure
The process of signing a HAP is as follows: The process of signing a HAP is as follows:
...@@ -242,9 +242,8 @@ The process of signing a HAP is as follows: ...@@ -242,9 +242,8 @@ The process of signing a HAP is as follows:
4. Sign the HAP. 4. Sign the HAP.
> **Precautions** <br/> > **Precautions** <br>
> For security purposes, the ECC algorithm is recommended for generating key pairs for application signing signatures. The RSA algorithm is not recommended.<br>
> For security purposes, the ECC algorithm is recommended for generating key pairs for application signing signatures. The RSA algorithm is not recommended.<br/>
> You are advised to place the HAP, profile, KS file **OpenHarmony.p12**, root CA certificate, intermediate CA certificate, and hapsigner in the same directory for easy operation. > You are advised to place the HAP, profile, KS file **OpenHarmony.p12**, root CA certificate, intermediate CA certificate, and hapsigner in the same directory for easy operation.
> The [**developtools_hapsigner/autosign/result**](https://gitee.com/openharmony/developtools_hapsigner/tree/master/autosign/result) directory has the following files:<br/>-&nbsp;OpenHarmony KS file **OpenHarmony.p12** <br/>-&nbsp;Root CA certificate **rootCA.cer**<br/>-&nbsp;Intermediate CA certificate **subCA.cer**<br/>-&nbsp;Profile signing certificate **OpenHarmonyProfileRelease.pem** > The [**developtools_hapsigner/autosign/result**](https://gitee.com/openharmony/developtools_hapsigner/tree/master/autosign/result) directory has the following files:<br/>-&nbsp;OpenHarmony KS file **OpenHarmony.p12** <br/>-&nbsp;Root CA certificate **rootCA.cer**<br/>-&nbsp;Intermediate CA certificate **subCA.cer**<br/>-&nbsp;Profile signing certificate **OpenHarmonyProfileRelease.pem**
...@@ -257,7 +256,7 @@ Example: ...@@ -257,7 +256,7 @@ Example:
```shell ```shell
java -jar hap-sign-tool.jar generate-keypair -keyAlias "oh-app1-key-v1" -keyAlg "ECC" -keySize "NIST-P-256" -keystoreFile "OpenHarmony.p12" -keyPwd "123456" -keystorePwd "123456" java -jar hap-sign-tool.jar generate-keypair -keyAlias "oh-app1-key-v1" -keyAlg "ECC" -keySize "NIST-P-256" -keystoreFile "OpenHarmony.p12" -keyPwd "123456" -keystorePwd "123456"
``` ```
> ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**<br/>Record the values of **keyAlias**, **keyStorePwd**, and **keyPwd**. These values will be used when the application signing certificate is generated and the HAP is signed. > ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**<br>Record the values of **keyAlias**, **keyStorePwd**, and **keyPwd**. These values will be used when the application signing certificate is generated and the HAP is signed.
The command parameters are described as follows: The command parameters are described as follows:
...@@ -286,12 +285,12 @@ The command parameters are described as follows: ...@@ -286,12 +285,12 @@ The command parameters are described as follows:
├── -keyAlias # Key alias, which must be the same as that in the previous step. ├── -keyAlias # Key alias, which must be the same as that in the previous step.
├── -signAlg # Signature algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory. ├── -signAlg # Signature algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory.
├── -issuer # Issuer of the certificate. Enter the issuer of the intermediate CA certificate. It is mandatory and cannot be changed. ├── -issuer # Issuer of the certificate. Enter the issuer of the intermediate CA certificate. It is mandatory and cannot be changed.
├── -issuerKeyAlias # Key alias of the issuer. Enter the key alias of the intermediate CA certificate. It is mandatory and cannot be changed. ├── -issuerKeyAlias # Key alias of the issuer. Enter the key alias of the intermediate CA certificate. This parameter is mandatory and cannot be changed.
├── -subject # Subject of the certificate. Enter the subject in the same sequence specified in the command. This parameter is mandatory. ├── -subject # Subject of the certificate. Enter the subject in the same sequence specified in the command. This parameter is mandatory.
├── -issuerKeyPwd # Key password of the issuer. Enter the key password of the intermediate CA certificate. It is mandatory and cannot be changed. In this example, it is 123456. ├── -issuerKeyPwd # Key password of the issuer. Enter the key password of the intermediate CA certificate. It is mandatory and cannot be changed. In this example, it is 123456.
├── -keystoreFile # KS file. Use OpenHarmony.p12. It is mandatory and cannot be changed. ├── -keystoreFile # KS file. Use OpenHarmony.p12. It is mandatory and cannot be changed.
├── -rootCaCertFile # Root certificate. It is mandatory and cannot be changed. ├── -rootCaCertFile # Root certificate. It is mandatory and cannot be changed.
├── -subCaCertFile # Intermediate CA certificate. It is mandatory and cannot be changed. ├── -subCaCertFile # Intermediate CA certificate provided. This parameter is mandatory and cannot be changed.
├── -outForm # Format of the certificate file to generate. certChain is recommended. ├── -outForm # Format of the certificate file to generate. certChain is recommended.
├── -outFile # File to generate. It is optional. The file is output to the console if this parameter is not specified. ├── -outFile # File to generate. It is optional. The file is output to the console if this parameter is not specified.
├── -keyPwd # Key password. It is optional. It is the key password set when the key pair is generated. ├── -keyPwd # Key password. It is optional. It is the key password set when the key pair is generated.
...@@ -331,12 +330,12 @@ Example: ...@@ -331,12 +330,12 @@ Example:
java -jar hap-sign-tool.jar sign-app -keyAlias "oh-app1-key-v1" -signAlg "SHA256withECDSA" -mode "localSign" -appCertFile "app1.pem" -profileFile "app1-profile.p7b" -inFile "app1-unsigned.zip" -keystoreFile "OpenHarmony.p12" -outFile "app1-signed.hap" -keyPwd "123456" -keystorePwd "123456" java -jar hap-sign-tool.jar sign-app -keyAlias "oh-app1-key-v1" -signAlg "SHA256withECDSA" -mode "localSign" -appCertFile "app1.pem" -profileFile "app1-profile.p7b" -inFile "app1-unsigned.zip" -keystoreFile "OpenHarmony.p12" -outFile "app1-signed.hap" -keyPwd "123456" -keystorePwd "123456"
``` ```
> ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**:<br/>The following parameters used are for the scenario where there is no application signing certificate available. If the application signing certificate is available, the following parameters need to be modified:<br/> > ![icon-note.gif](../public_sys-resources/icon-note.gif) **NOTE**:<br>The following parameters used are for the scenario where there is no application signing certificate available. If the application signing certificate is available, the following parameters need to be modified:<br>
-**keyAlias**: Enter the key alias of the application signing certificate. This parameter is mandatory. <br/> -**keyAlias**: Enter the key alias of the application signing certificate. This parameter is mandatory. <br>
-**appCertFile**: Enter the application signing certificate. This parameter is mandatory.<br/> -**appCertFile**: Enter the application signing certificate. This parameter is mandatory.<br>
-**keystoreFile**: Enter the KS file of the application signing certificate. This parameter is mandatory. <br/> -**keystoreFile**: Enter the KS file of the application signing certificate. This parameter is mandatory. <br>
-**keyPwd**: Enter the key password in the KS file. <br/> -**keyPwd**: Enter the key password in the KS file. <br>
-**keystorePwd**: Enter the KS password in the KS file.<br/> -**keystorePwd**: Enter the KS password in the KS file.<br>
The command parameters are described as follows: The command parameters are described as follows:
...@@ -344,7 +343,7 @@ The command parameters are described as follows: ...@@ -344,7 +343,7 @@ The command parameters are described as follows:
├──-keyAlias # Key alias, which must be the same as the alias of the key pair generated. This parameter is mandatory. ├──-keyAlias # Key alias, which must be the same as the alias of the key pair generated. This parameter is mandatory.
├── -signAlg # Signature algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory. ├── -signAlg # Signature algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory.
├── -mode # Signing mode, which must be localSign. It is mandatory. ├── -mode # Signing mode, which must be localSign. It is mandatory.
├── -appCertFile # Application signing certificate (certificate chain, in the end-entity certificate, intermediate CA certificate, and root certificate order). Enter the application signing certificate generated. This parameter is mandatory. ├── -appCertFile # Application signing certificate (certificate chain, in the end-entity certificate, intermediate CA certificate, and root certificate order). Enter the application signing certificate generated in step 2. This parameter is mandatory.
├── -profileFile # Signed provisioning profile in p7b format. Enter the profile generated. This parameter is mandatory. ├── -profileFile # Signed provisioning profile in p7b format. Enter the profile generated. This parameter is mandatory.
├── -inFile # Raw application package. It is mandatory. ├── -inFile # Raw application package. It is mandatory.
├── -keystoreFile # KS file, which must be the same as the KS file generated. It is mandatory and cannot be changed. ├── -keystoreFile # KS file, which must be the same as the KS file generated. It is mandatory and cannot be changed.
...@@ -353,6 +352,13 @@ The command parameters are described as follows: ...@@ -353,6 +352,13 @@ The command parameters are described as follows:
├── -keystorePwd # KS password, which must be the actual KS password. ├── -keystorePwd # KS password, which must be the actual KS password.
## FAQs ## FAQs
**1. When the application signing certificate is generated, the console displays the result but no file is output.** **1. When the application signing certificate is generated, the console displays the result but no file is output.**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册