提交 dd09c5a2 编写于 作者: 张悦诶

new HarmonyAppProvison configuration file

Signed-off-by: N张悦诶 <zhangyue230@h-partners.com>
上级 07c451db
......@@ -71,3 +71,7 @@ httpRequest.request(
}
);
```
## Samples
The following sample is provided to help you better understand how to develop the HTTP data request feature:
- [`Http`: HTTP Data Request (eTS) (API 8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Http)
......@@ -122,3 +122,7 @@ The implementation is similar for UDPSocket and TCPSocket. The following uses th
tcp.off('close');
}, 30 * 1000);
```
## Samples
The following sample is provided to help you better understand how to develop the socket connection feature:
- [`Socket`: Socket Connection (eTS) (API 8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Socket)
......@@ -75,4 +75,4 @@ In this example, an application event is logged after the application startup ex
The following sample is provided to help you better understand how to develop the application event logging feature:
- [`JsDotTest`: Event Logging Test (JavaScript) (API 7)](https://gitee.com/openharmony/app_samples/tree/master/DFX/JsDotTest)
- [`JsDotTest`: Event Logging Test (JavaScript) (API 8)](https://gitee.com/openharmony/app_samples/tree/master/DFX/JsDotTest)
# Ability Access Control
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 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.
## Modules to Import
```
```js
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
```
......@@ -26,7 +26,7 @@ Creates an **AtManager** instance, which is used for ability access control.
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
```
......@@ -57,7 +57,7 @@ Checks whether an application has been granted the specified permission. This AP
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let promise = AtManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
......@@ -92,7 +92,7 @@ Grants a user granted permission to an application. This API uses a promise to r
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
......@@ -124,7 +124,7 @@ Grants a user granted permission to an application. This API uses an asynchronou
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let permissionFlag = 1;
......@@ -159,7 +159,7 @@ Revokes a user granted permission given to an application. This API uses a promi
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let permissionFlag = 1;
......@@ -190,7 +190,7 @@ Revokes a user granted permission given to an application. This API uses an asyn
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => {
......@@ -223,7 +223,7 @@ Obtains the flags of the specified permission of a given application. This API u
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let promise = AtManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
......
......@@ -7,7 +7,7 @@
## Modules to Import
```
```js
import call from '@ohos.telephony.call';
```
......@@ -30,7 +30,7 @@ Initiates a call. This API uses an asynchronous callback to return the execution
**Example**
```
```js
call.dial("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -57,7 +57,7 @@ Initiates a call. You can set call options as needed. This API uses an asynchron
**Example**
```
```js
call.dial("138xxxxxxxx", {
extras: false
}, (err, data) => {
......@@ -91,7 +91,7 @@ Initiates a call. You can set call options as needed. This API uses a promise to
**Example**
```
```js
let promise = call.dial("138xxxxxxxx", {
extras: false
});
......@@ -121,7 +121,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example**
```
```js
call.makeCall("138xxxxxxxx", err => {
console.log(`makeCall callback: err->${JSON.stringify(err)}`);
});
......@@ -152,7 +152,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example**
```
```js
let promise = call.makeCall("138xxxxxxxx");
promise.then(() => {
console.log(`makeCall success`);
......@@ -177,7 +177,7 @@ Checks whether a call is in progress. This API uses an asynchronous callback to
**Example**
```
```js
call.hasCall((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -200,7 +200,7 @@ Checks whether a call is in progress. This API uses a promise to return the resu
**Example**
```
```js
let promise = call.hasCall();
promise.then(data => {
console.log(`hasCall success, promise: data->${JSON.stringify(data)}`);
......@@ -226,7 +226,7 @@ Obtains the call status. This API uses an asynchronous callback to return the re
**Example**
```
```js
call.getCallState((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -249,7 +249,7 @@ Obtains the call status. This API uses a promise to return the result.
**Example**
```
```js
let promise = call.getCallState();
promise.then(data => {
console.log(`getCallState success, promise: data->${JSON.stringify(data)}`);
......@@ -272,7 +272,7 @@ Checks whether a device supports voice calls. This API works in synchronous mode
| ------- | ------------------------------------------------------------ |
| boolean | - **true**: The device supports voice calls.<br>- **false**: The device does not support voice calls.|
```
```js
let result = call.hasVoiceCapability();
console.log(`hasVoiceCapability: ${JSON.stringify(result)}`);
```
......@@ -294,7 +294,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
**Example**
```
```js
call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -319,7 +319,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
**Example**
```
```js
call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -349,7 +349,7 @@ Checks whether the call number of the SIM card in the specified slot is an emerg
**Example**
```
```js
let promise = call.isEmergencyPhoneNumber("138xxxxxxxx", {slotId: 1});
promise.then(data => {
console.log(`isEmergencyPhoneNumber success, promise: data->${JSON.stringify(data)}`);
......@@ -375,7 +375,7 @@ Formats a phone number based on the specified ISO country code. This API uses an
**Example**
```
```js
call.formatPhoneNumber("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -400,7 +400,7 @@ Formats a phone number based on specified formatting options. This API uses an a
**Example**
```
```js
call.formatPhoneNumber("138xxxxxxxx",{
countryCode: "CN"
}, (err, data) => {
......@@ -432,7 +432,7 @@ Formats a phone number based on specified formatting options. This API uses a pr
**Example**
```
```js
let promise = call.formatPhoneNumber("138xxxxxxxx", {
countryCode: "CN"
});
......@@ -465,7 +465,7 @@ All country codes are supported.
**Example**
```
```js
call.formatPhoneNumberToE164("138xxxxxxxx",{
countryCode: "CN"
}, (err, data) => {
......@@ -501,7 +501,7 @@ All country codes are supported.
**Example**
```
```js
let promise = call.formatPhoneNumberToE164("138xxxxxxxx", {
countryCode: "CN"
});
......
......@@ -7,7 +7,7 @@
## Modules to Import
```
```js
import contact from '@ohos.contact';
```
......@@ -29,7 +29,7 @@ Adds a contact. This API uses an asynchronous callback to return the result.
**Example**
```
```js
contact.addContact({
fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
......@@ -65,7 +65,7 @@ Adds a contact. This API uses a promise to return the result.
**Example**
```
```js
let promise = contact.addContact({
name: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
......@@ -96,7 +96,7 @@ Deletes a contact based on the specified contact key. This API uses an asynchron
**Example**
```
```js
contact.deleteContact('xxx', (err) => {
if (err) {
console.log(`deleteContact callback: err->${JSON.stringify(err)}`);
......@@ -129,7 +129,7 @@ Deletes a contact based on the specified contact key. This API uses a promise to
**Example**
```
```js
let promise = contact.deleteContact('xxx');
promise.then(() => {
console.log(`deleteContact success`);
......@@ -157,7 +157,7 @@ Updates a contact based on the specified contact information. This API uses an a
**Example**
```
```js
contact.updateContact({
name: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
......@@ -190,7 +190,7 @@ Updates a contact based on the specified contact information and attributes. Thi
**Example**
```
```js
contact.updateContact({
fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
......@@ -229,7 +229,7 @@ Updates a contact based on the specified contact information and attributes. Thi
**Example**
```
```js
let promise = contact.updateContact({
fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
......@@ -262,7 +262,7 @@ Checks whether the ID of this contact is in the local address book. This API use
**Example**
```
```js
contact.isLocalContact(/*id*/1, (err, data) => {
if (err) {
console.log(`isLocalContact callback: err->${JSON.stringify(err)}`);
......@@ -295,7 +295,7 @@ Checks whether the ID of this contact is in the local address book. This API use
**Example**
```
```js
let promise = contact.isLocalContact(/*id*/1);
promise.then((data) => {
console.log(`isLocalContact success: data->${JSON.stringify(data)}`);
......@@ -323,7 +323,7 @@ Checks whether a contact is included in my card. This API uses an asynchronous c
**Example**
```
```js
contact.isMyCard(/*id*/1, (err, data) => {
if (err) {
console.log(`isMyCard callback: err->${JSON.stringify(err)}`);
......@@ -356,7 +356,7 @@ Checks whether a contact is included in my card. This API uses a promise to retu
**Example**
```
```js
let promise = contact.isMyCard(/*id*/1);
promise.then((data) => {
console.log(`isMyCard success: data->${JSON.stringify(data)}`);
......@@ -383,7 +383,7 @@ Queries my card. This API uses an asynchronous callback to return the result.
**Example**
```
```js
contact.queryMyCard((err, data) => {
if (err) {
console.log(`queryMyCard callback: err->${JSON.stringify(err)}`);
......@@ -412,7 +412,7 @@ Queries my card based on the specified contact attributes. This API uses an asyn
**Example**
```
```js
contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME']
}, (err, data) => {
......@@ -447,7 +447,7 @@ Queries my card based on the specified contact attributes. This API uses a promi
**Example**
```
```js
let promise = contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME']
});
......@@ -478,7 +478,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example**
```
```js
contact.selectContact((err, data) => {
if (err) {
console.log(`selectContact callback: err->${JSON.stringify(err)}`);
......@@ -508,7 +508,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Example**
```
```js
let promise = contact.selectContact();
promise.then((data) => {
console.log(`selectContact success: data->${JSON.stringify(data)}`);
......@@ -536,7 +536,7 @@ Queries a contact based on the specified key. This API uses an asynchronous call
**Example**
```
```js
contact.queryContact('xxx', (err, data) => {
if (err) {
console.log(`queryContact callback: err->${JSON.stringify(err)}`);
......@@ -566,7 +566,7 @@ Queries contacts based on the specified key and application. This API uses an as
**Example**
```
```js
contact.queryContact('xxx', {
holderId: 0
}, (err, data) => {
......@@ -598,7 +598,7 @@ Queries contacts based on the specified key and attributes. This API uses an asy
**Example**
```
```js
contact.queryContact('xxx', {
attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => {
......@@ -631,7 +631,7 @@ Queries contacts based on the specified key, application, and attributes. This A
**Example**
```
```js
contact.queryContact('xxx', {
holderId: 0
}, {
......@@ -670,7 +670,7 @@ Queries contacts based on the specified key, application, and attributes. This A
**Example**
```
```js
let promise = contact.queryContact('xxx', {
holderId: 0
}, {
......@@ -701,7 +701,7 @@ Queries all contacts. This API uses an asynchronous callback to return the resul
**Example**
```
```js
contact.queryContacts((err, data) => {
if (err) {
console.log(`queryContacts callback: err->${JSON.stringify(err)}`);
......@@ -730,7 +730,7 @@ Queries all contacts based on the specified application. This API uses an asynch
**Example**
```
```js
contact.queryContacts({
holderId: 0
}, (err, data) => {
......@@ -761,7 +761,7 @@ Queries all contacts based on the specified attributes. This API uses an asynchr
**Example**
```
```js
contact.queryContacts({
attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => {
......@@ -793,7 +793,7 @@ Queries all contacts based on the specified application and attributes. This API
**Example**
```
```js
contact.queryContacts({
holderId: 0
}, {
......@@ -831,7 +831,7 @@ Queries all contacts based on the specified application and attributes. This API
**Example**
```
```js
let promise = contact.queryContacts({
holderId: 0
}, {
......@@ -863,7 +863,7 @@ Queries contacts based on the specified phone number. This API uses an asynchron
**Example**
```
```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', (err, data) => {
if (err) {
console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`);
......@@ -893,7 +893,7 @@ Queries contacts based on the specified phone number and application. This API u
**Example**
```
```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', {
holderId: 0
}, (err, data) => {
......@@ -925,7 +925,7 @@ Queries contacts based on the specified phone number and attributes. This API us
**Example**
```
```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', {
attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => {
......@@ -958,7 +958,7 @@ Queries contacts based on the specified phone number, application, and attribute
**Example**
```
```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', {
holderId: 0
}, {
......@@ -997,7 +997,7 @@ Queries contacts based on the specified phone number, application, and attribute
**Example**
```
```js
let promise = contact.queryContactsByPhoneNumber('138xxxxxxxx', {
holderId: 0
}, {
......@@ -1029,7 +1029,7 @@ Queries contacts based on the specified email address. This API uses an asynchro
**Example**
```
```js
contact.queryContactsByEmail('xxx@email.com', (err, data) => {
if (err) {
console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`);
......@@ -1059,7 +1059,7 @@ Queries contacts based on the specified email address and application. This API
**Example**
```
```js
contact.queryContactsByEmail('xxx@email.com', {
holderId: 0
}, (err, data) => {
......@@ -1091,7 +1091,7 @@ Queries contacts based on the specified email address and attributes. This API u
**Example**
```
```js
contact.queryContactsByEmail('xxx@email.com', {
attributes: ["ATTR_EMAIL", "ATTR_NAME"]
}, (err, data) => {
......@@ -1124,7 +1124,7 @@ Queries contacts based on the specified email address, application, and attribut
**Example**
```
```js
contact.queryContactsByEmail('xxx@email.com', {
holderId: 0
}, {
......@@ -1163,7 +1163,7 @@ Queries contacts based on the specified email address, application, and attribut
**Example**
```
```js
let promise = contact.queryContactsByEmail('xxx@email.com', {
holderId: 0
}, {
......@@ -1194,7 +1194,7 @@ Queries all groups of this contact. This API uses an asynchronous callback to re
**Example**
```
```js
contact.queryGroups((err, data) => {
if (err) {
console.log(`queryGroups callback: err->${JSON.stringify(err)}`);
......@@ -1223,7 +1223,7 @@ Queries all groups of this contact based on the specified application. This API
**Example**
```
```js
contact.queryGroups({
holderId: 0
}, (err, data) => {
......@@ -1258,7 +1258,7 @@ Queries all groups of this contact based on the specified application. This API
**Example**
```
```js
let promise = contact.queryGroups({
holderId: 0
});
......@@ -1287,7 +1287,7 @@ Queries all applications that have created contacts. This API uses an asynchrono
**Example**
```
```js
contact.queryHolders((err, data) => {
if (err) {
console.log(`queryHolders callback: err->${JSON.stringify(err)}`);
......@@ -1315,7 +1315,7 @@ Queries all applications that have created contacts. This API uses a promise to
**Example**
```
```js
let promise = contact.queryHolders();
promise.then((data) => {
console.log(`queryHolders success: data->${JSON.stringify(data)}`);
......@@ -1343,7 +1343,7 @@ Queries the key of a contact based on the specified contact ID. This API uses an
**Example**
```
```js
contact.queryKey(/*id*/1, (err, data) => {
if (err) {
console.log(`queryKey callback: err->${JSON.stringify(err)}`);
......@@ -1373,7 +1373,7 @@ Queries the key of a contact based on the specified contact ID and application.
**Example**
```
```js
contact.queryKey(id, {
holderId:1
}, (err, data) => {
......@@ -1409,7 +1409,7 @@ Queries the key of a contact based on the specified contact ID and application.
**Example**
```
```js
let promise = contact.queryKey(id, {
holderId: 0
});
......@@ -1462,7 +1462,7 @@ Defines a contact.
Create contact data in JSON format:
```
```js
let myContact = {
phoneNumbers: [{
phoneNumber: "138xxxxxxxx"
......@@ -1480,7 +1480,7 @@ let myContact = {
Or, create data by configuring a new Contact object.
```
```js
let myContact = new contact.Contact();
let name = new contact.Name();
name.fullName = "fullName";
......@@ -1508,7 +1508,7 @@ If **null** is passed, all attributes are queried by default.
Create contact data in JSON format:
```
```js
let contactAttributes = {
attributes: [
contact.Attribute.ATTR_EMAIL,
......@@ -1521,7 +1521,7 @@ let contactAttributes = {
Or, create data by configuring a **ContactAttributes** object.
```
```js
let contactAttributes = new contact.ContactAttributes();
contactAttributes.attributes = ["ATTR_EMAIL"];
```
......@@ -1555,7 +1555,7 @@ Enumerates contact attributes.
Create contact data in JSON format:
```
```js
let attributes = [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME, contact.Attribute.ATTR_PHONE];
```
......@@ -1591,7 +1591,7 @@ Defines a contact's email.
Create contact data in JSON format:
```
```js
let email = {
email: "xxx@email.com",
displayName: "displayName"
......@@ -1601,7 +1601,7 @@ let email = {
Or, create data by configuring an **Email** object.
```
```js
let email = new contact.Email();
email.email = "xxx@email.com";
```
......@@ -1624,7 +1624,7 @@ Defines an application that creates the contact.
Create contact data in JSON format:
```
```js
let holder = {
holderId: 0
};
......@@ -1632,7 +1632,7 @@ let holder = {
Or, create data by configuring a **Holder** object.
```
```js
let holder = new contact.Holder();
holder.holderId = 0;
```
......@@ -1668,7 +1668,7 @@ Defines a contact's event.
Create contact data in JSON format:
```
```js
let event = {
eventDate: "xxxxxx"
};
......@@ -1676,7 +1676,7 @@ let event = {
Or, create data by configuring an **Event** object.
```
```js
let event = new contact.Event();
event.eventDate = "xxxxxx";
```
......@@ -1698,7 +1698,7 @@ Defines a contact group.
Create contact data in JSON format:
```
```js
let group = {
groupId: 1,
title: "title"
......@@ -1707,7 +1707,7 @@ let group = {
Or, create data by configuring a **Group** object.
```
```js
let group = new contact.Group();
group.title = "title";
```
......@@ -1747,7 +1747,7 @@ Enumerates IM addresses.
Create contact data in JSON format:
```
```js
let imAddress = {
imAddress: "imAddress",
labelName: "labelName"
......@@ -1757,7 +1757,7 @@ let imAddress = {
Or, create data by configuring an **ImAddress** object.
```
```js
let imAddress = new contact.ImAddress();
imAddress.imAddress = "imAddress";
```
......@@ -1786,7 +1786,7 @@ Defines a contact's name.
Create contact data in JSON format:
```
```js
let name = {
familyName: "familyName",
fullName: "fullName"
......@@ -1795,7 +1795,7 @@ let name = {
Or, create data by configuring a **Name** object.
```
```js
let name = new contact.Name();
name.familyName = "familyName";
name.fullName = "fullName";
......@@ -1817,7 +1817,7 @@ Defines a contact's nickname.
Create contact data in JSON format:
```
```js
let nickName = {
nickName: "nickName"
};
......@@ -1825,7 +1825,7 @@ let nickName = {
Or, create data by configuring a **NickName** object.
```
```js
let nickName = new contact.NickName();
nickName.nickName = "nickName";
```
......@@ -1846,7 +1846,7 @@ Defines a contact's note.
Create contact data in JSON format:
```
```js
let note = {
noteContent: "noteContent"
};
......@@ -1854,7 +1854,7 @@ let note = {
Or, create data by configuring a **Note** object.
```
```js
let note = new contact.Note();
note.noteContent = "noteContent";
```
......@@ -1876,7 +1876,7 @@ Defines a contact's organization.
Create contact data in JSON format:
```
```js
let organization = {
name: "name",
title: "title"
......@@ -1885,7 +1885,7 @@ let organization = {
Or, create data by configuring an **Organization** object.
```
```js
let organization = new contact.Organization();
organization.name = "name";
organization.title = "title";
......@@ -1939,7 +1939,7 @@ Defines a contact's phone number.
Create contact data in JSON format:
```
```js
let phoneNumber = {
phoneNumber: "138xxxxxxxx",
labelId: contact.PhoneNumber.NUM_HOME
......@@ -1948,7 +1948,7 @@ let phoneNumber = {
Or, create data by configuring a new **PhoneNumber** object.
```
```js
let phoneNumber = new contact.PhoneNumber();
phoneNumber.phoneNumber = "138xxxxxxxx";
```
......@@ -1969,7 +1969,7 @@ Defines a contact's portrait.
Create contact data in JSON format:
```
```js
let portrait = {
uri: "uri"
};
......@@ -1977,7 +1977,7 @@ let portrait = {
Or, create data by configuring a new **Portrait** object.
```
```js
let portrait = new contact.Portrait();
portrait.uri = "uri";
```
......@@ -2020,7 +2020,7 @@ Defines a contact's postal address.
Create contact data in JSON format:
```
```js
let postalAddress = {
city: "city"
};
......@@ -2028,7 +2028,7 @@ let postalAddress = {
Or, create data by configuring a new **PostalAddress** object.
```
```js
let postalAddress = new contact.PostalAddress();
postalAddress.city = "city";
```
......@@ -2075,7 +2075,7 @@ Defines a contact's relationship.
Create contact data in JSON format:
```
```js
let relation = {
relationName: "relationName",
labelId: contact.Relation.RELATION_ASSISTANT
......@@ -2084,7 +2084,7 @@ let relation = {
Or, create data by configuring a new **Relation** object.
```
```js
let relation = new contact.Relation();
relation.relationName = "relationName";
relation.labelId = contact.Relation.RELATION_ASSISTANT;
......@@ -2121,7 +2121,7 @@ Defines a contact's SIP address.
Create contact data in JSON format:
```
```js
var sipAddress = {
sipAddress: "sipAddress"
};
......@@ -2129,7 +2129,7 @@ var sipAddress = {
Or, create data by configuring a new **SipAddress** object.
```
```js
let sipAddress = new contact.SipAddress();
sipAddress.sipAddress = "sipAddress";
```
......@@ -2150,7 +2150,7 @@ Defines a contact's website.
Create contact data in JSON format:
```
```js
let website = {
website: "website"
};
......@@ -2158,7 +2158,7 @@ let website = {
Or, create data by configuring a new **Website** object.
```
```js
let website = new contact.Website();
website.website = "website";
```
# XML-to-JavaScript Conversion
> **NOTE**
> **NOTE**<br/>
> 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.
## Modules to Import
```
```js
import convertxml from '@ohos.convertxml';
```
## System Capabilities
SystemCapability.Utils.Lang
## ConvertXML
......@@ -23,61 +19,66 @@ convert(xml: string, options?: ConvertOptions) : Object
Converts an XML text into a JavaScript object.
**System capability**: SystemCapability.Utils.Lang
- Parameters
**Parameters**
| Name| Type| Mandatory| Description|
| ------- | --------------------------------- | ---- | ------------------ |
| xml | string | Yes| XML text to convert.|
| options | [ConvertOptions](#convertoptions) | No| Settings of the convert operation.|
| Name | Type | Mandatory| Description |
| ------- | --------------------------------- | ---- | --------------- |
| xml | string | Yes | XML text to convert.|
| options | [ConvertOptions](#convertoptions) | No | Options for coversion. |
- Return value
**Return value**
| Type| Description|
| ------ | ---------------------------- |
| Object | JavaScript object.|
| Type | Description |
| ------ | ---------------------------- |
| Object | JavaScript object.|
- Example
**Example**
```js
let xml =
```js
let xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
let conv = new convertxml.ConvertXML();
let options = {trim : false, declarationKey:"_declaration",
let conv = new convertxml.ConvertXML();
let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options));
console.log(result)
```
let result = JSON.stringify(conv.convert(xml, options));
console.log(result)
```
## ConvertOptions
| Name| Type| Mandatory| Description|
Options for coversion.
**System capability**: SystemCapability.Utils.Lang
| Name | Type| Mandatory| Description |
| ----------------- | -------- | ---- | ----------------------------------------------------------- |
| trim | boolean | Yes| Whether to trim the whitespace characters before and after the text. The default value is **false**.|
| ignoreDeclaration | boolean | No| Whether to ignore the XML declaration. The default value is **false**.|
| ignoreInstruction | boolean | No| Whether to ignore the XML processing instruction. The default value is **false**.|
| ignoreAttributes | boolean | No| Whether to print attributes across multiple lines and indent attributes. The default value is **false**.|
| ignoreComment | boolean | No| Whether to ignore element comments. The default value is **false**.|
| ignoreCDATA | boolean | No| Whether to ignore the element's CDATA information. The default value is **false**.|
| ignoreDoctype | boolean | No| Whether to ignore the element's Doctype information. The default value is **false**.|
| ignoreText | boolean | No| Whether to ignore the element's text information. The default value is **false**.|
| declarationKey | string | Yes| Name of the attribute key for **declaration** in the output object. The default value is **_declaration**.|
| instructionKey | string | Yes| Name of the attribute key for **instruction** in the output object. The default value is **_instruction**.|
| attributesKey | string | Yes| Name of the attribute key for **attributes** in the output object. The default value is **_attributes**.|
| textKey | string | Yes| Name of the attribute key for **text** in the output object. The default value is **_text**.|
| cdataKey | string | Yes| Name of the attribute key for **CDATA** in the output object. The default value is **_cdata**.|
| doctypeKey | string | Yes| Name of the attribute key for **Doctype** in the output object. The default value is **_doctype**.|
| commentKey | string | Yes| Name of the attribute key for **comment** in the output object. The default value is **_comment**.|
| parentKey | string | Yes| Name of the attribute key for **parent** in the output object. The default value is **_parent**.|
| typeKey | string | Yes| Name of the attribute key for **type** in the output object. The default value is **_type**.|
| nameKey | string | Yes| Name of the attribute key for **name** in the output object. The default value is **_name**.|
| elementsKey | string | Yes| Name of the attribute key for **elements** in the output object. The default value is **_elements**.|
| trim | boolean | Yes | Whether to trim the whitespace characters before and after the text. The default value is **false**. |
| ignoreDeclaration | boolean | No | Whether to ignore the XML declaration. The default value is **false**. |
| ignoreInstruction | boolean | No | Whether to ignore the XML processing instruction. The default value is **false**. |
| ignoreAttributes | boolean | No | Whether to print attributes across multiple lines and indent attributes. The default value is **false**. |
| ignoreComment | boolean | No | Whether to ignore element comments. The default value is **false**. |
| ignoreCDATA | boolean | No | Whether to ignore the element's CDATA information. The default value is **false**. |
| ignoreDoctype | boolean | No | Whether to ignore the element's Doctype information. The default value is **false**. |
| ignoreText | boolean | No | Whether to ignore the element's text information. The default value is **false**. |
| declarationKey | string | Yes | Name of the attribute key for **declaration** in the output object. The default value is **_declaration**.|
| instructionKey | string | Yes | Name of the attribute key for **instruction** in the output object. The default value is **_instruction**.|
| attributesKey | string | Yes | Name of the attribute key for **attributes** in the output object. The default value is **_attributes**. |
| textKey | string | Yes | Name of the attribute key for **text** in the output object. The default value is **_text**. |
| cdataKey | string | Yes | Name of the attribute key for **CDATA** in the output object. The default value is **_cdata**. |
| doctypeKey | string | Yes | Name of the attribute key for **Doctype** in the output object. The default value is **_doctype**. |
| commentKey | string | Yes | Name of the attribute key for **comment** in the output object. The default value is **_comment**. |
| parentKey | string | Yes | Name of the attribute key for **parent** in the output object. The default value is **_parent**. |
| typeKey | string | Yes | Name of the attribute key for **type** in the output object. The default value is **_type**. |
| nameKey | string | Yes | Name of the attribute key for **name** in the output object. The default value is **_name**. |
| elementsKey | string | Yes | Name of the attribute key for **elements** in the output object. The default value is **_elements**. |
# Display
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **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.
## Modules to Import
......@@ -58,13 +58,12 @@ Obtains the default display object.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
- Parameters
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the default display object.|
- Example
**Example**
```js
var displayClass = null;
display.getDefaultDisplay((err, data) => {
......@@ -85,13 +84,13 @@ Obtains the default display object.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
- Return value
**Return value**
| Type | Description |
| ---------------------------------- | ---------------------------------------------- |
| Promise&lt;[Display](#display)&gt; | Promise used to return the default display object.|
- Example
**Example**
```js
let promise = display.getDefaultDisplay();
......@@ -110,13 +109,13 @@ Obtains all the display objects.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
- Parameters
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------- | ---- | ------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[Display](#display)&gt;&gt; | Yes | Callback used to return all the display objects.|
- Example
**Example**
```js
display.getAllDisplay((err, data) => {
......@@ -136,13 +135,13 @@ Obtains all the display objects.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
- Return value
**Return value**
| Type | Description |
| ----------------------------------------------- | ------------------------------------------------------- |
| Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return an array containing all the display objects.|
- Example
**Example**
```js
let promise = display.getAllDisplay();
......@@ -161,14 +160,13 @@ Enables listening.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
- Parameters
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed|
| callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.|
- Example
**Example**
```js
var type = "add";
var callback = (data) => {
......@@ -186,14 +184,13 @@ Disables listening.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
- Parameters
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed|
| callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.|
- Example
**Example**
```js
var type = "remove";
display.off(type);
......
# Fault Logger
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 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.
## Modules to Import
```
```js
import faultLogger from '@ohos.faultLogger'
```
......@@ -56,7 +56,7 @@ Obtains the fault information about the current process. This API uses a callbac
**Example**
```
```js
function queryFaultLogCallback(error, value) {
if (error) {
console.info('error is ' + error);
......@@ -101,7 +101,7 @@ Obtains the fault information about the current process. This API uses a promise
**Example**
```
```js
async function getLog() {
let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH);
if (value) {
......
# HiDebug
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> 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.
You can run the hidebug command to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. You can also export VM memory slices and collect VM CPU profiling data.
......@@ -20,7 +20,7 @@ Obtains the total size of the native heap memory.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value**
**Return value**
| Type | Description |
| ------ | --------------------------- |
......@@ -42,7 +42,7 @@ Obtains the size of the allocated native heap memory.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value**
**Return value**
| Type | Description |
| ------ | --------------------------------- |
| bigint | Size of the allocated native heap memory.|
......@@ -63,7 +63,7 @@ Obtains the size of the free native heap memory.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value**
**Return value**
| Type | Description |
| ------ | ------------------------------- |
| bigint | Size of the free native heap memory.|
......@@ -84,7 +84,7 @@ Obtains the PSS of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value**
**Return value**
| Type | Description |
| ------ | ------------------------- |
| bigint | PSS of the process.|
......@@ -105,7 +105,7 @@ Obtains the size of the shared dirty memory of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value**
**Return value**
| Type | Description |
| ------ | -------------------------- |
| bigint | Size of the shared dirty memory of the process.|
......@@ -116,6 +116,47 @@ Obtains the size of the shared dirty memory of this process.
let sharedDirty = hidebug.getSharedDirty();
```
## hidebug.getPrivateDirty<sup>9+<sup>
getPrivateDirty(): bigint
Obtains the size of the private dirty memory of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value**
| Type | Description |
| ------ | -------------------------- |
| bigint | Size of the private dirty memory of the process.|
**Example**
```js
let privateDirty = hidebug.getPrivateDirty();
```
## hidebug.getCpuUsage<sup>9+<sup>
getCpuUsage(): number
Obtains the CPU usage of this process.
For example, if the CPU usage is **50%**, **0.5** is returned.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value**
| Type | Description |
| ------ | -------------------------- |
| number | CPU usage of the process.|
**Example**
```js
let cpuUsage = hidebug.getCpuUsage();
```
## hidebug.startProfiling
......@@ -135,9 +176,9 @@ Starts the profiling method. `startProfiling()` and `stopProfiling()` are called
```js
hidebug.startProfiling("cpuprofiler-20220216");
// Code block
// code block
// ...
// Code block
// code block
hidebug.stopProfiling();
```
......@@ -147,7 +188,7 @@ hidebug.stopProfiling();
stopProfiling() : void
Stops the profiling method. `stopProfiling()` and `startProfiling()` are called in pairs. `stopProfiling()` always occurs after `startProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`.
Stops the profiling method. `startProfiling()` and `stopProfiling()` are called in pairs. `startProfiling()` always occurs before `stopProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
......@@ -155,9 +196,9 @@ Stops the profiling method. `stopProfiling()` and `startProfiling()` are called
```js
hidebug.startProfiling("cpuprofiler-20220216");
// Code block
// code block
// ...
// Code block
// code block
hidebug.stopProfiling();
```
......@@ -165,13 +206,13 @@ hidebug.stopProfiling();
dumpHeapData(filename : string) : void
Exports the heap data.
Exports data from the specified heap file.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| filename | string | Yes | User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the app based on the specified `filename`.|
......@@ -180,3 +221,31 @@ Exports the heap data.
```js
hidebug.dumpHeapData("heap-20220216");
```
## hidebug.getServiceDump<sup>9+<sup>
getServiceDump(serviceid : number) : string
Obtains information on the specified system service.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| serviceid | number | Yes | ID of the system service. |
**Return value**
| Type | Description |
| ------ | -------------------------- |
| string | Absolute path of the file that contains the service information to dump. |
**Example**
```js
let serviceId = 10;
let pathName = hidebug.getServiceDump(serviceId);
```
......@@ -7,13 +7,13 @@
## Modules to Import
```
```js
import http from '@ohos.net.http';
```
## Example
```
```js
import http from '@ohos.net.http';
// Each HttpRequest corresponds to an HttpRequestTask object and cannot be reused.
......@@ -71,7 +71,7 @@ Creates an HTTP request. You can use this API to initiate or destroy an HTTP req
**Example**
```
```js
import http from '@ohos.net.http';
let httpRequest = http.createHttp();
```
......@@ -100,7 +100,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback
**Example**
```
```js
httpRequest.request("EXAMPLE_URL", (err, data) => {
if (!err) {
console.info('Result:' + data.result);
......@@ -133,7 +133,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
**Example**
```
```js
httpRequest.request("EXAMPLE_URL",
{
method: http.RequestMethod.GET,
......@@ -183,7 +183,7 @@ Initiates an HTTP request to a given URL. This API uses a promise to return the
**Example**
```
```js
let promise = httpRequest.request("EXAMPLE_URL", {
method: http.RequestMethod.GET,
connectTimeout: 60000,
......@@ -214,7 +214,7 @@ Destroys an HTTP request.
**Example**
```
```js
httpRequest.destroy();
```
......@@ -239,7 +239,7 @@ Registers an observer for HTTP Response Header events.
**Example**
```
```js
httpRequest.on('headerReceive', (err, data) => {
if (!err) {
console.info('header: ' + JSON.stringify(data));
......@@ -273,7 +273,7 @@ Unregisters the observer for HTTP Response Header events.
**Example**
```
```js
httpRequest.off('headerReceive');
```
......@@ -294,7 +294,7 @@ Registers an observer for HTTP Response Header events.
**Example**
```
```js
httpRequest.on('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header));
});
......@@ -322,7 +322,7 @@ Unregisters the observer for HTTP Response Header events.
**Example**
```
```js
httpRequest.off('headersReceive');
```
......@@ -343,7 +343,7 @@ Registers a one-time observer for HTTP Response Header events. Once triggered, t
**Example**
```
```js
httpRequest.once('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header));
});
......
......@@ -7,7 +7,7 @@
## Modules to Import
```javascript
```js
import connection from '@ohos.net.connection'
```
......@@ -29,7 +29,7 @@ Obtains the default active data network. This API uses an asynchronous callback
**Example**
```javascript
```js
connection.getDefaultNet(function (error, netHandle) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(netHandle))
......@@ -54,7 +54,7 @@ Obtains the default active data network. This API uses a promise to return the r
**Example**
```javascript
```js
connection.getDefaultNet().then(function (netHandle) {
console.log(JSON.stringify(netHandle))
})
......@@ -76,7 +76,7 @@ Checks whether the default data network is activated. This API uses an asynchron
**Example**
```javascript
```js
connection.hasDefaultNet(function (error, has) {
console.log(JSON.stringify(error))
console.log(has)
......@@ -99,7 +99,7 @@ Checks whether the default data network is activated. This API uses a promise to
**Example**
```javascript
```js
connection.hasDefaultNet().then(function (has) {
console.log(has)
})
......@@ -122,7 +122,7 @@ Obtains the list of all active data networks. This API uses an asynchronous call
**Example**
```
```js
connection.getAllNets(function (error, nets) {
console.log(JSON.stringify(error))
console.log(JSON.stringify(nets))
......@@ -147,7 +147,7 @@ Obtains the list of all active data networks. This API uses a promise to return
**Example**
```
```js
connection.getAllNets().then(function (nets) {
console.log(JSON.stringify(nets))
});
......@@ -172,7 +172,7 @@ Obtains connection properties of the network corresponding to given network hand
**Example**
```javascript
```js
connection.getDefaultNet().then(function (netHandle) {
connection.getConnectionProperties(netHandle, function (error, info) {
console.log(JSON.stringify(error))
......@@ -205,7 +205,7 @@ Obtains connection properties of the network corresponding to **netHandle**. Thi
**Example**
```javascript
```js
connection.getDefaultNet().then(function (netHandle) {
connection.getConnectionProperties(netHandle).then(function (info) {
console.log(JSON.stringify(info))
......@@ -232,7 +232,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th
**Example**
```javascript
```js
connection.getDefaultNet().then(function (netHandle) {
connection.getNetCapabilities(netHandle, function (error, info) {
console.log(JSON.stringify(error))
......@@ -265,7 +265,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th
**Example**
```javascript
```js
connection.getDefaultNet().then(function (netHandle) {
connection.getNetCapabilities(netHandle).then(function (info) {
console.log(JSON.stringify(info))
......@@ -291,7 +291,7 @@ Reports connection of the data network. This API uses an asynchronous callback t
**Example**
```
```js
connection.getDefaultNet().then(function (netHandle) {
connection.reportNetConnected(netHandle, function (error) {
console.log(JSON.stringify(error))
......@@ -322,7 +322,7 @@ Reports connection of the data network. This API uses a promise to return the re
**Example**
```
```js
connection.getDefaultNet().then(function (netHandle) {
connection.reportNetConnected(netHandle).then(function () {
console.log(`report success`)
......@@ -349,7 +349,7 @@ Reports disconnection of the data network. This API uses an asynchronous callbac
**Example**
```
```js
connection.getDefaultNet().then(function (netHandle) {
connection.reportNetDisconnected(netHandle, function (error) {
console.log(JSON.stringify(error))
......@@ -380,7 +380,7 @@ Reports disconnection of the data network. This API uses a promise to return the
**Example**
```
```js
connection.getDefaultNet().then(function (netHandle) {
connection.reportNetDisconnected(netHandle).then(function () {
console.log(`report success`)
......@@ -407,7 +407,7 @@ Resolves the host name by using the default network to obtain all IP addresses.
**Example**
```
```js
let host = "xxxx";
connection.getAddressesByName(host, function (error, addresses) {
console.log(JSON.stringify(error))
......@@ -439,7 +439,7 @@ Resolves the host name by using the default network to obtain all IP addresses.
**Example**
```
```js
let host = "xxxx";
connection.getAddressesByName(host).then(function (addresses) {
console.log(JSON.stringify(addresses))
......@@ -469,7 +469,7 @@ Obtains the handle of the network specified by **netSpecifier**.
**Example**
```javascript
```js
// Default network
let netConnection = connection.createNetConnection()
......@@ -502,7 +502,7 @@ Registers a listener for **netAvailable** events.
**Example**
```javascript
```js
netConnection.on('netAvailable', function (data) {
console.log(JSON.stringify(data))
})
......@@ -525,7 +525,7 @@ Registers a listener for **netCapabilitiesChange** events.
**Example**
```javascript
```js
netConnection.on('netCapabilitiesChange', function (data) {
console.log(JSON.stringify(data))
})
......@@ -548,7 +548,7 @@ Registers a listener for **netConnectionPropertiesChange** events.
**Example**
```javascript
```js
netConnection.on('netConnectionPropertiesChange', function (data) {
console.log(JSON.stringify(data))
})
......@@ -571,7 +571,7 @@ Registers a listener for **netBlockStatusChange** events.
**Example**
```javascript
```js
netConnection.on('netBlockStatusChange', function (data) {
console.log(JSON.stringify(data))
})
......@@ -594,7 +594,7 @@ Registers a listener for **netLost** events.
**Example**
```javascript
```js
let netConnection1 = connection.createNetConnection()
netConnection1.on('netLost', function (data) {
console.log(JSON.stringify(data))
......@@ -618,7 +618,7 @@ Registers a listener for **netUnavailable** events.
**Example**
```javascript
```js
netConnection.on('netUnavailable', function (data) {
console.log(JSON.stringify(data))
})
......@@ -642,7 +642,7 @@ Registers a listener for network status changes.
**Example**
```javascript
```js
netConnection.register(function (error) {
console.log(JSON.stringify(error))
})
......@@ -664,7 +664,7 @@ Unregisters the listener for network status changes.
**Example**
```javascript
```js
netConnection.unregister(function (error) {
console.log(JSON.stringify(error))
})
......@@ -703,7 +703,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre
**Example**
```javascript
```js
connection.getDefaultNet().then(function (netHandle) {
let host = "xxxx";
netHandle.getAddressesByName(host, function (error, addresses) {
......@@ -737,7 +737,7 @@ Resolves the host name by using the corresponding network to obtain all IP addre
**Example**
```javascript
```js
connection.getDefaultNet().then(function (netHandle) {
let host = "xxxx";
netHandle.getAddressesByName(host).then(function (addresses) {
......@@ -765,7 +765,7 @@ Resolves the host name by using the corresponding network to obtain the first IP
**Example**
```javascript
```js
connection.getDefaultNet().then(function (netHandle) {
let host = "xxxx";
netHandle.getAddressByName(host, function (error, address) {
......@@ -799,7 +799,7 @@ Resolves the host name by using the corresponding network to obtain the first IP
**Example**
```javascript
```js
connection.getDefaultNet().then(function (netHandle) {
let host = "xxxx";
netHandle.getAddressByName(host).then(function (address) {
......
......@@ -7,7 +7,7 @@
## Modules to Import
```
```js
import observer from '@ohos.telephony.observer'
```
......@@ -30,7 +30,7 @@ Registers an observer for network status change events. This API uses an asynchr
**Example**
```
```js
observer.on('networkStateChange', data =>{
console.log("on networkStateChange, data:" + JSON.stringify(data));
});
......@@ -57,7 +57,7 @@ Registers an observer for network status change events of the SIM card in the sp
**Example**
```
```js
observer.on('networkStateChange', {slotId: 0}, data =>{
console.log("on networkStateChange, data:" + JSON.stringify(data));
});
......@@ -87,7 +87,7 @@ Unregisters the observer for network status change events. This API uses an asyn
**Example**
```
```js
let callback = data => {
console.log("on networkStateChange, data:" + JSON.stringify(data));
}
......@@ -114,7 +114,7 @@ Registers an observer for signal status change events. This API uses an asynchro
**Example**
```
```js
observer.on('signalInfoChange', data =>{
console.log("on signalInfoChange, data:" + JSON.stringify(data));
});
......@@ -139,7 +139,7 @@ Registers an observer for signal status change events of the SIM card in the spe
**Example**
```
```js
observer.on('signalInfoChange', {slotId: 0}, data =>{
console.log("on signalInfoChange, data:" + JSON.stringify(data));
});
......@@ -167,7 +167,7 @@ Unregisters the observer for signal status change events. This API uses an async
**Example**
```
```js
let callback = data => {
console.log("on signalInfoChange, data:" + JSON.stringify(data));
}
......@@ -197,7 +197,7 @@ Registers an observer for call status change events. This API uses an asynchrono
**Example**
```
```js
observer.on('callStateChange', value =>{
console.log("on callStateChange, state:" + value.state + ", number:" + value.number);
});
......@@ -224,7 +224,7 @@ Registers an observer for call status change events. This API uses an asynchrono
**Example**
```
```js
observer.on('callStateChange', {slotId: 0}, value =>{
console.log("on callStateChange, state:" + value.state + ", number:" + value.number);
});
......@@ -254,7 +254,7 @@ Unregisters the observer for call status change events. This API uses an asynchr
**Example**
```
```js
let callback = value => {
console.log("on callStateChange, state:" + value.state + ", number:" + value.number);
}
......@@ -282,7 +282,7 @@ Registers an observer for connection status change events of the cellular data l
**Example**
```
```js
observer.on('cellularDataConnectionStateChange', value =>{
console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network);
});
......@@ -307,7 +307,7 @@ Registers an observer for connection status change events of the cellular data l
**Example**
```
```js
observer.on('cellularDataConnectionStateChange', {slotId: 0}, value =>{
console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network);
});
......@@ -335,7 +335,7 @@ Unregisters the observer for connection status change events of the cellular dat
**Example**
```
```js
let callback = value => {
console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network);
}
......@@ -363,7 +363,7 @@ Registers an observer for the uplink and downlink data flow status change events
**Example**
```
```js
observer.on('cellularDataFlowChange', data =>{
console.log("on networkStateChange, data:" + JSON.stringify(data));
});
......@@ -388,7 +388,7 @@ Registers an observer for the uplink and downlink data flow status change events
**Example**
```
```js
observer.on('cellularDataFlowChange', {slotId: 0}, data =>{
console.log("on cellularDataFlowChange, data:" + JSON.stringify(data));
});
......@@ -416,7 +416,7 @@ Unregisters the observer for the uplink and downlink data flow status change eve
**Example**
```
```js
let callback = data => {
console.log("on cellularDataFlowChange, data:" + JSON.stringify(data));
}
......@@ -444,7 +444,7 @@ Registers an observer for SIM card status change events. This API uses an asynch
**Example**
```
```js
observer.on('simStateChange', data =>{
console.log("on simStateChange, data:" + JSON.stringify(data));
});
......@@ -469,7 +469,7 @@ Registers an observer for status change events of the SIM card in the specified
**Example**
```
```js
observer.on('simStateChange', {slotId: 0}, data =>{
console.log("on simStateChange, data:" + JSON.stringify(data));
});
......@@ -497,7 +497,7 @@ Unregisters the observer for SIM card status change events. This API uses an asy
**Example**
```
```js
let callback = data => {
console.log("on simStateChange, data:" + JSON.stringify(data));
}
......
......@@ -17,13 +17,13 @@ import process from '@ohos.process';
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| egid | number | Yes| No| Effective group identifier (EGID) of a process.|
| euid | number | Yes| No| Effective user identifier (EUID) of a process.|
| gid | number | Yes| No| Group identifier (GID) of a process.|
| egid | number | Yes| No| Effective group identifier (EGID) of a process. This is a system API and cannot be called by third-party applications.|
| euid | number | Yes| No| Effective user identifier (EUID) of a process. This is a system API and cannot be called by third-party applications.|
| gid | number | Yes| No| Group identifier (GID) of a process. This is a system API and cannot be called by third-party applications.|
| uid | number | Yes| No| User identifier (UID) of a process.|
| groups | number[] | Yes| No| Array with supplementary group IDs.|
| groups | number[] | Yes| No| Array with supplementary group IDs. This is a system API and cannot be called by third-party applications.|
| pid | number | Yes| No| Process ID (PID) of a process.|
| ppid | number | Yes| No| Parent process ID (PPID) of a process.|
| ppid | number | Yes| No| Parent process ID (PPID) of a process. This is a system API and cannot be called by third-party applications.|
| tid<sup>8+</sup> | number | Yes| No| Thread ID (TID) of a process.|
......@@ -38,10 +38,10 @@ Allows a process to obtain the standard input and output of its child processes,
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| pid | number | Yes| No| PID of the child process.|
| ppid | number | Yes| No| PPID of the child process.|
| exitCode | number | Yes| No| Exit code of the child process.|
| killed | boolean | Yes| No| Whether the parent process successfully sends a signal to the child process to terminate it.|
| pid | number | Yes| No| PID of the child process. This is a system API and cannot be called by third-party applications.|
| ppid | number | Yes| No| PPID of the child process. This is a system API and cannot be called by third-party applications.|
| exitCode | number | Yes| No| Exit code of the child process. This is a system API and cannot be called by third-party applications.|
| killed | boolean | Yes| No| Whether the parent process successfully sends a signal to the child process to terminate it. This is a system API and cannot be called by third-party applications.|
### wait
......@@ -50,6 +50,8 @@ wait(): Promise&lt;number&gt;
Waits until the child process ends. This method uses a promise to return the exit code of the child process.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang
**Return value**
......@@ -75,6 +77,8 @@ getOutput(): Promise&lt;Uint8Array&gt;
Obtains the standard output of the child process.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang
**Return value**
......@@ -100,6 +104,8 @@ getErrorOutput(): Promise&lt;Uint8Array&gt;
Obtains the standard error output of the child process.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang
**Return value**
......@@ -125,6 +131,8 @@ close(): void
Closes the child process in running.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang
**Example**
......@@ -141,6 +149,8 @@ kill(signal: number | string): void
Sends a signal to the specified child process to terminate it.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
......@@ -383,6 +393,8 @@ runCmd(command: string, options?: { timeout : number, killSignal : number | stri
Forks a new process to run a shell command and returns the **ChildProcess** object.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
......@@ -438,6 +450,8 @@ on(type: string, listener: EventListener): void
Stores the events triggered by the user.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
......@@ -468,6 +482,8 @@ off(type: string): boolean
Deletes the event stored by the user.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
......@@ -521,6 +537,8 @@ cwd(): string
Obtains the working directory of this process.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang
**Example**
......@@ -536,6 +554,8 @@ chdir(dir: string): void
Changes the working directory of this process.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.Utils.Lang
**Parameters**
......@@ -594,6 +614,7 @@ Sends a signal to the specified process to terminate it.
| boolean | Returns **true** if the signal is sent successfully; returns **false** otherwise.|
**Example**
```js
var pres = process.pid
var result = that.kill(28, pres)
......
......@@ -7,7 +7,7 @@
## Modules to Import
```
```js
import radio from '@ohos.telephony.radio'
```
......@@ -30,7 +30,7 @@ Obtains the radio access technology (RAT) used by the CS and PS domains. This AP
**Example**
```
```js
let slotId = 0;
radio.getRadioTech(slotId, (err, data) =>{
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -62,7 +62,7 @@ Obtains the RAT used by the CS and PS domains. This API uses a promise to return
**Example**
```
```js
let slotId = 0;
let promise = radio.getRadioTech(slotId);
promise.then(data => {
......@@ -91,7 +91,7 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Example**
```
```js
radio.getNetworkState((err, data) =>{
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -117,7 +117,7 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Example**
```
```js
let slotId = 0;
radio.getNetworkState(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -149,7 +149,7 @@ Obtains the network status of the SIM card in the specified slot. This API uses
**Example**
```
```js
let slotId = 0;
let promise = radio.getNetworkState(slotId);
promise.then(data => {
......@@ -177,7 +177,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
**Example**
```
```js
let slotId = 0;
radio.getNetworkSelectionMode(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -207,7 +207,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
**Example**
```
```js
let slotId = 0;
let promise = radio.getNetworkSelectionMode(slotId);
promise.then(data => {
......@@ -235,7 +235,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci
**Example**
```
```js
let slotId = 0;
radio.getISOCountryCodeForNetwork(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -265,7 +265,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci
**Example**
```
```js
let slotId = 0;
let promise = radio.getISOCountryCodeForNetwork(slotId);
promise.then(data => {
......@@ -292,7 +292,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a
**Example**
```
```js
radio.getPrimarySlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -315,7 +315,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a
**Example**
```
```js
let promise = radio.getPrimarySlotId();
promise.then(data => {
console.log(`getPrimarySlotId success, promise: data->${JSON.stringify(data)}`);
......@@ -342,7 +342,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the
**Example**
```
```js
let slotId = 0;
radio.getSignalInformation(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -372,7 +372,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the
**Example**
```
```js
let slotId = 0;
let promise = radio.getSignalInformation(slotId);
promise.then(data => {
......@@ -405,7 +405,7 @@ Checks whether the current device supports 5G \(NR\).
**Example**
```
```js
let slotId = 0;
let result = radio.isNrSupported(slotId);
console.log(result);
......@@ -430,7 +430,7 @@ Checks whether the radio service is enabled on the primary SIM card. This API us
**Example**
```
```js
radio.isRadioOn((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -456,7 +456,7 @@ Checks whether the radio service is enabled on the SIM card in the specified slo
**Example**
```
```js
let slotId = 0;
radio.isRadioOn(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -488,7 +488,7 @@ Checks whether the radio service is enabled. This API uses a promise to return t
**Example**
```
```js
let slotId = 0;
let promise = radio.isRadioOn(slotId);
promise.then(data => {
......@@ -516,7 +516,7 @@ Obtains the carrier name. This API uses an asynchronous callback to return the r
**Example**
```
```js
let slotId = 0;
radio.getOperatorName(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -546,7 +546,7 @@ Obtains the carrier name. This API uses a promise to return the result.
**Example**
```
```js
let slotId = 0;
let promise = radio.getOperatorName(slotId);
promise.then(data => {
......
# Screenshot
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **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.
## Modules to Import
......@@ -58,14 +58,14 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal
**Required permissions**: ohos.permission.CAPTURE_SCREEN
- Parameters
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.|
| callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return a **PixelMap** object. |
- Example
**Example**
```js
var ScreenshotOptions = {
......@@ -98,19 +98,19 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro
**Required permissions**: ohos.permission.CAPTURE_SCREEN
- Parameters
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.|
- Return value
**Return value**
| Type | Description |
| ----------------------------- | ----------------------------------------------- |
| Promise&lt;image.PixelMap&gt; | Promise used to return an **image.PixelMap** object.|
- Example
**Example**
```js
var ScreenshotOptions = {
......
......@@ -7,7 +7,7 @@
## Modules to Import
```
```js
import sim from '@ohos.telephony.sim';
```
......@@ -28,7 +28,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses an
**Example**
```
```js
sim.isSimActive(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -57,7 +57,7 @@ Checks whether the SIM card in the specified slot is activated. This API uses a
**Example**
```
```js
let promise = sim.isSimActive(0);
promise.then(data => {
console.log(`isSimActive success, promise: data->${JSON.stringify(data)}`);
......@@ -83,7 +83,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A
**Example**
```
```js
sim.getDefaultVoiceSlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -106,7 +106,7 @@ Obtains the default slot ID of the SIM card that provides voice services. This A
**Example**
```
```js
let promise = sim.getDefaultVoiceSlotId();
promise.then(data => {
console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`);
......@@ -132,7 +132,7 @@ Checks whether the application (caller) has been granted the operator permission
**Example**
```
```js
sim.hasOperatorPrivileges(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -160,7 +160,7 @@ Checks whether the application (caller) has been granted the operator permission
**Example**
```
```js
let promise = sim.hasOperatorPrivileges(0);
promise.then(data => {
console.log(`hasOperatorPrivileges success, promise: data->${JSON.stringify(data)}`);
......@@ -186,7 +186,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use
**Example**
```
```js
sim.getISOCountryCodeForSim(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -215,7 +215,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use
**Example**
```
```js
let promise = sim.getISOCountryCodeForSim(0);
promise.then(data => {
console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`);
......@@ -242,7 +242,7 @@ Obtains the public land mobile network (PLMN) ID of the SIM card in the specifie
**Example**
```
```js
sim.getSimOperatorNumeric(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -271,7 +271,7 @@ Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promi
**Example**
```
```js
let promise = sim.getSimOperatorNumeric(0);
promise.then(data => {
console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`);
......@@ -298,7 +298,7 @@ Obtains the service provider name (SPN) of the SIM card in the specified slot. T
**Example**
```
```js
sim.getSimSpn(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -327,7 +327,7 @@ Obtains the SPN of the SIM card in the specified slot. This API uses a promise t
**Example**
```
```js
let promise = sim.getSimSpn(0);
promise.then(data => {
console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`);
......@@ -354,7 +354,7 @@ Obtains the status of the SIM card in the specified slot. This API uses an async
**Example**
```
```js
sim.getSimState(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -383,7 +383,7 @@ Obtains the status of the SIM card in the specified slot. This API uses a promis
**Example**
```
```js
let promise = sim.getSimState(0);
promise.then(data => {
console.log(`getSimState success, promise: data->${JSON.stringify(data)}`);
......@@ -409,7 +409,7 @@ Obtains the type of the SIM card in the specified slot. This API uses an asynchr
**Example**
```
```js
sim.getCardType(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -438,7 +438,7 @@ Obtains the type of the SIM card in the specified slot. This API uses a promise
**Example**
```
```js
let promise = sim.getCardType(0);
promise.then(data => {
console.log(`getCardType success, promise: data->${JSON.stringify(data)}`);
......@@ -465,7 +465,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses an
**Example**
```
```js
sim.hasSimCard(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -494,7 +494,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses a
**Example**
```
```js
let promise = sim.hasSimCard(0);
promise.then(data => {
console.log(`hasSimCard success, promise: data->${JSON.stringify(data)}`);
......@@ -520,7 +520,7 @@ Obtains the number of card slots.
**Example**
```
```js
console.log(sim.getMaxSimCount())
```
......
......@@ -6,7 +6,7 @@
## Modules to Import
```
```js
import sms from '@ohos.telephony.sms';
```
......@@ -28,7 +28,7 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp
**Example**
```
```js
const specification = '3gpp';
// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...].
const pdu = [0x08, 0x91];
......@@ -61,7 +61,7 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol.
**Example**
```
```js
const specification = '3gpp';
// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...].
const pdu = [0x08, 0x91];
......@@ -91,7 +91,7 @@ Sends an SMS message.
**Example**
```
```js
let sendCallback = function (err, data) {
console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}
......@@ -124,7 +124,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use
**Example**
```
```js
sms.getDefaultSmsSlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -147,7 +147,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use
**Example**
```
```js
let promise = sms.getDefaultSmsSlotId();
promise.then(data => {
console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`);
......@@ -179,7 +179,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```
```js
let slotId = 0;
let smscAddr = '+861xxxxxxxxxx';
sms.setSmscAddr(slotId, smscAddr, (err,data) => {
......@@ -215,7 +215,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```
```js
let slotId = 0;
let smscAddr = '+861xxxxxxxxxx';
let promise = sms.setSmscAddr(slotId, smscAddr);
......@@ -248,7 +248,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```
```js
let slotId = 0;
sms.getSmscAddr(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -282,7 +282,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```
```js
let slotId = 0;
let promise = sms.getSmscAddr(slotId);
promise.then(data => {
......@@ -306,7 +306,7 @@ Checks whether the current device can send and receive SMS messages. This API wo
| ------- | ------------------------------------------------------------ |
| boolean | - **true**: The device can send and receive SMS messages.<br>- **false**: The device cannot send or receive SMS messages.|
```
```js
let result = sms.hasSmsCapability();
console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
```
......
......@@ -7,7 +7,7 @@
## Modules to Import
```
```js
import socket from '@ohos.net.socket';
```
......@@ -28,7 +28,7 @@ Creates a **UDPSocket** object.
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
```
......@@ -56,7 +56,7 @@ Binds the IP address and port number. The port number can be specified or random
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
if (err) {
......@@ -93,7 +93,7 @@ Binds the IP address and port number. The port number can be specified or random
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
let promise = udp.bind({address: '192.168.xx.xxx', port: 8080, family: 1});
promise .then(() => {
......@@ -123,7 +123,7 @@ Sends data over a UDPSocket connection. This API uses an asynchronous callback t
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
udp.send({
data:'Hello, server!',
......@@ -166,7 +166,7 @@ Sends data over a UDPSocket connection. This API uses a promise to return the re
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
let promise = udp.send({
data:'Hello, server!',
......@@ -202,7 +202,7 @@ Closes a UDPSocket connection. This API uses an asynchronous callback to return
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
udp.close(err => {
if (err) {
......@@ -232,7 +232,7 @@ Closes a UDPSocket connection. This API uses a promise to return the result.
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
let promise = udp.close();
promise.then(() => {
......@@ -264,7 +264,7 @@ Obtains the status of the UDPSocket connection. This API uses an asynchronous ca
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
if (err) {
......@@ -304,7 +304,7 @@ Obtains the status of the UDPSocket connection. This API uses a promise to retur
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
if (err) {
......@@ -345,7 +345,7 @@ Sets other properties of the UDPSocket connection. This API uses an asynchronous
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}, err=> {
if (err) {
......@@ -397,7 +397,7 @@ Sets other properties of the UDPSocket connection. This API uses a promise to re
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
let promise = udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1});
promise.then(() => {
......@@ -437,7 +437,7 @@ Enables listening for message receiving events of the UDPSocket connection. This
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
udp.on('message', value => {
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
......@@ -465,7 +465,7 @@ Disables listening for message receiving events of the UDPSocket connection. Thi
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
let callback = value =>{
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
......@@ -494,7 +494,7 @@ Enables listening for data packet message events or close events of the UDPSocke
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
udp.on('listening', () => {
console.log("on listening success");
......@@ -525,7 +525,7 @@ Disables listening for data packet message events or close events of the UDPSock
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
let callback1 = () =>{
console.log("on listening, success");
......@@ -562,7 +562,7 @@ Enables listening for error events of the UDPSocket connection. This API uses an
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
udp.on('error', err => {
console.log("on error, err:" + JSON.stringify(err))
......@@ -590,7 +590,7 @@ Disables listening for error events of the UDPSocket connection. This API uses a
**Example**
```
```js
let udp = socket.constructUDPSocketInstance();
let callback = err =>{
console.log("on error, err:" + JSON.stringify(err));
......@@ -680,7 +680,7 @@ Creates a **TCPSocket** object.
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
```
......@@ -709,7 +709,7 @@ Binds the IP address and port number. The port number can be specified or random
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
if (err) {
......@@ -745,7 +745,7 @@ Binds the IP address and port number. The port number can be specified or random
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let promise = tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1});
promise.then(() => {
......@@ -775,7 +775,7 @@ Sets up a connection to the specified IP address and port number. This API uses
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}, err => {
if (err) {
......@@ -811,7 +811,7 @@ Sets up a connection to the specified IP address and port number. This API uses
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => {
......@@ -844,7 +844,7 @@ Sends data over a TCPSocket connection. This API uses an asynchronous callback t
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => {
......@@ -891,7 +891,7 @@ Sends data over a TCPSocket connection. This API uses a promise to return the re
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise1.then(() => {
......@@ -929,7 +929,7 @@ Closes a TCPSocket connection. This API uses an asynchronous callback to return
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
tcp.close(err => {
if (err) {
......@@ -959,7 +959,7 @@ Closes a TCPSocket connection. This API uses a promise to return the result.
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let promise = tcp.close();
promise.then(() => {
......@@ -991,7 +991,7 @@ Obtains the remote address of a TCPSocket connection. This API uses an asynchron
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => {
......@@ -1030,7 +1030,7 @@ Obtains the remote address of a TCPSocket connection. This API uses a promise to
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise1.then(() => {
......@@ -1069,7 +1069,7 @@ Obtains the status of the TCPSocket connection. This API uses an asynchronous ca
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => {
......@@ -1109,7 +1109,7 @@ Obtains the status of the TCPSocket connection. This API uses a promise to retur
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => {
......@@ -1148,7 +1148,7 @@ Sets other properties of the TCPSocket connection. This API uses an asynchronous
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => {
......@@ -1203,7 +1203,7 @@ Sets other properties of the TCPSocket connection. This API uses a promise to re
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000});
promise.then(() => {
......@@ -1246,7 +1246,7 @@ Enables listening for message receiving events of the TCPSocket connection. This
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
tcp.on('message', value => {
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo)
......@@ -1274,7 +1274,7 @@ Disables listening for message receiving events of the TCPSocket connection. Thi
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let callback = value =>{
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
......@@ -1304,7 +1304,7 @@ Enables listening for connection or close events of the TCPSocket connection. Th
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
tcp.on('connect', () => {
console.log("on connect success")
......@@ -1335,7 +1335,7 @@ Disables listening for connection or close events of the TCPSocket connection. T
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let callback1 = () =>{
console.log("on connect success");
......@@ -1371,7 +1371,7 @@ Enables listening for error events of the TCPSocket connection. This API uses an
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
tcp.on('error', err => {
console.log("on error, err:" + JSON.stringify(err))
......@@ -1399,7 +1399,7 @@ Disables listening for error events of the TCPSocket connection. This API uses a
**Example**
```
```js
let tcp = socket.constructTCPSocketInstance();
let callback = err =>{
console.log("on error, err:" + JSON.stringify(err));
......
......@@ -5,7 +5,7 @@
## Modules to Import
```
```js
import usb from "@ohos.usb";
```
......@@ -17,13 +17,13 @@ Obtains the USB device list.
**System capability**: SystemCapability.USB.USBManager
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| Array&lt;Readonly&lt;[USBDevice](#usbdevice)&gt;&gt; | Device information list.|
- Example
```
- **Example**
```js
let devicesList = usb.getDevices();
console.log(`devicesList = ${JSON.stringify(devicesList)}`);
// devicesList is a list of USB devices.
......@@ -89,18 +89,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| device | [USBDevice](#usbdevice) | Yes| USB device information.|
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| Readonly&lt;[USBDevicePipe](#usbdevicepipe)&gt; | USB device pipe for data transfer.|
- Example
```
- **Example**
```js
let devicepipe= usb.connectDevice(device);
console.log(`devicepipe = ${JSON.stringify(devicepipe)}`);
```
......@@ -114,18 +114,18 @@ Checks whether the application has the permission to access the device.
**System capability**: SystemCapability.USB.USBManager
- Parameters
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name.|
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.|
- Example
```
- **Example**
```js
let divicesName="1-1";
let bool = usb.hasRight(divicesName);
console.log(bool);
......@@ -140,18 +140,18 @@ Requests the temporary permission for the application to access the USB device.
**System capability**: SystemCapability.USB.USBManager
- Parameters
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name.|
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise.|
- Example
```
- **Example**
```js
let divicesName="1-1";
usb.requestRight(divicesName).then((ret) => {
console.log(`requestRight = ${JSON.stringify(ret)}`);
......@@ -169,20 +169,20 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim.|
| force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface.|
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.|
- Example
```
- **Example**
```js
let ret = usb.claimInterface(devicepipe, interfaces);
console.log(`claimInterface = ${ret}`);
```
......@@ -198,19 +198,19 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c
**System capability**: SystemCapability.USB.USBManager
- Parameters
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release.|
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.|
- Example
```
- **Example**
```js
let ret = usb.releaseInterface(devicepipe, interfaces);
console.log(`releaseInterface = ${ret}`);
```
......@@ -226,19 +226,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| config | [USBConfig](#usbconfig) | Yes| USB configuration to set.|
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.|
- Example
```
- **Example**
```js
let ret = usb.setConfiguration(devicepipe, config);
console.log(`setConfiguration = ${ret}`);
```
......@@ -254,19 +254,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| iface | [USBInterface](#usbinterface) | Yes| USB interface to set.|
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.|
- Example
```
- **Example**
```js
let ret = usb.setInterface(devicepipe, interfaces);
console.log(`setInterface = ${ret}`);
```
......@@ -282,18 +282,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| Uint8Array | Raw descriptor data.|
- Example
```
- **Example**
```js
let ret = usb.getRawDescriptor(devicepipe);
```
......@@ -308,18 +308,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| number | File descriptor of the USB device.|
- Example
```
- **Example**
```js
let ret = usb.getFileDescriptor(devicepipe);
```
......@@ -334,20 +334,20 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.|
| contrlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters.|
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.|
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.|
- Example
```
- **Example**
```js
usb.controlTransfer(devicepipe, USBControlParams).then((ret) => {
console.log(`controlTransfer = ${JSON.stringify(ret)}`);
})
......@@ -364,7 +364,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.|
......@@ -372,13 +372,13 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
| buffer | Uint8Array | Yes| Buffer for writing or reading data.|
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.|
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.|
- Example
```
- **Example**
```js
// Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission.
// Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device.
// Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer.
......@@ -398,18 +398,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.|
- Return value
- **Return value**
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.|
- Example
```
- **Example**
```js
let ret = usb.closePipe(devicepipe);
console.log(`closePipe = ${ret}`);
```
......
......@@ -12,13 +12,13 @@ If an error occurs in any of the preceding processes, the client will receive a
## Modules to Import
```
```js
import webSocket from '@ohos.net.webSocket';
```
## Complete Example
```
```js
import webSocket from '@ohos.net.webSocket';
var defaultIpAddress = "ws://";
......@@ -78,7 +78,7 @@ Creates a WebSocket connection. You can use this API to create or close a WebSoc
**Example**
```
```js
let ws = webSocket.createWebSocket();
```
......@@ -107,7 +107,7 @@ Initiates a WebSocket request to establish a WebSocket connection to a given URL
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
ws.connect(url, (err, value) => {
......@@ -141,7 +141,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
ws.connect(url, {
......@@ -184,7 +184,7 @@ Initiates a WebSocket request carrying specified options to establish a WebSocke
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
let promise = ws.connect(url);
......@@ -215,7 +215,7 @@ Sends data through a WebSocket connection. This API uses an asynchronous callbac
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
ws.connect(url, (err, value) => {
......@@ -254,7 +254,7 @@ Sends data through a WebSocket connection. This API uses a promise to return the
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
ws.connect(url, (err, value) => {
......@@ -286,7 +286,7 @@ Closes a WebSocket connection. This API uses an asynchronous callback to return
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
ws.close((err, value) => {
......@@ -318,7 +318,7 @@ Closes a WebSocket connection carrying specified options such as **code** and **
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
ws.close({
......@@ -358,7 +358,7 @@ Closes a WebSocket connection carrying specified options such as **code** and **
**Example**
```
```js
let ws = webSocket.createWebSocket();
let url = "ws://"
let promise = ws.close({
......@@ -391,7 +391,7 @@ Enables listening for the **open** events of a WebSocket connection. This API us
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.on('open', (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
......@@ -419,7 +419,7 @@ Disables listening for the **open** events of a WebSocket connection. This API u
**Example**
```
```js
let ws = webSocket.createWebSocket();
let callback1 = (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
......@@ -451,7 +451,7 @@ Enables listening for the **message** events of a WebSocket connection. This API
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.on('message', (err, value) => {
console.log("on message, message:" + value);
......@@ -480,7 +480,7 @@ Disables listening for the **message** events of a WebSocket connection. This AP
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.off('message');
```
......@@ -503,7 +503,7 @@ Enables listening for the **close** events of a WebSocket connection. This API u
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.on('close', (err, value) => {
console.log("on close, code is " + value.code + ", reason is " + value.reason);
......@@ -532,7 +532,7 @@ Disables listening for the **close** events of a WebSocket connection. This API
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.off('close');
```
......@@ -556,7 +556,7 @@ Enables listening for the **error** events of a WebSocket connection. This API u
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.on('error', (err) => {
console.log("on error, error:" + JSON.stringify(err))
......@@ -584,7 +584,7 @@ Disables listening for the **error** events of a WebSocket connection. This API
**Example**
```
```js
let ws = webSocket.createWebSocket();
ws.off('error');
```
......
# webgl
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **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.
......@@ -13,16 +13,16 @@ Create a **<canvas\>** component in the HML file. The following is an example:
```
<div class="container">
<canvas ref="canvas1" style="width : 400px; height : 200px; background-color : lightyellow;"></canvas>
<button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button>
</div>
```
Obtain the **<canvas\>** component instance in the JS file. The following is an example:
```
```js
// Obtain the <canvas> component instance.
const el = this.$refs.canvas1;
// Obtain the WebGL context from the <canvas> component instance.
......
# webgl2
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **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.
......@@ -13,16 +13,16 @@ Create a **<canvas\>** component in the HML file. The following is an example:
```
<div class="container">
<canvas ref="canvas1" style="width : 400px; height : 200px; background-color : lightyellow;"></canvas>
<button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button>
</div>
```
Obtain the **<canvas\>** component instance in the JS file. The following is an example:
```
```js
// Obtain the <canvas> component instance.
const el = this.$refs.canvas1;
// Obtain the WebGL context from the <canvas> component instance.
......
......@@ -240,8 +240,8 @@ typedef struct { // Good: The anonymous struct is used because self-nesting i
int a;
int b;
} MyType; // The struct alias uses the UpperCamelCase style.
```c
```
```c
typedef struct tagNode { // Good: Add the 'tag' prefix or use 'Node_'.
struct tagNode *prev;
struct tagNode *next;
......
......@@ -70,9 +70,9 @@ The HDF-based driver development involves driver implementation and configuratio
2. Build the driver.<br/>
- LiteOS<br/>
Modify **makefile** and **BUILD.gn**.
Modify the **Makefile** and **BUILD.gn** files.
- **makefile**:<br/>
- **Makefile**:<br/>
Use the **makefile** template provided by the HDF to compile the driver code.
......@@ -90,7 +90,7 @@ The HDF-based driver development involves driver implementation and configuratio
```
LITEOS_BASELIB += -lxxx # Static library generated by the link.
LIB_SUBDIRS += # Directory in which the driver code makefile is located.
LIB_SUBDIRS += # Directory in which Makefile is located.
```
- **BUILD.gn**:<br/>
......@@ -141,7 +141,7 @@ The HDF-based driver development involves driver implementation and configuratio
obj-$(CONFIG_DRIVERS_HDF) += xxx/
```
Add a **Makefile** to the driver directory **xxx** and add code compiling rules of the driver to the **Makefile** file.
Add a **Makefile** to the driver directory **xxx** and add code compiling rules of the driver to the file.
```
......
......@@ -230,7 +230,7 @@ The WLAN driver is developed based on the HDF and PLATFORM. It provides a unifie
5. Initialize the bus.
6. Mount the upper-layer WPA service.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE:**<br>
>Some of the above adaptation steps have been provided. For details, see [Development Example](#section1395253612512). The steps waiting to be performed by developers include setting configuration parameters based on hardware attributes, adapting and mounting a chip, and performing tests and verification.
## Development Example<a name="section1395253612512"></a>
......@@ -604,4 +604,3 @@ hi_void HiMac80211Init(struct HdfChipDriver *chipDriver)
chipDriver->apOps = &g_apOps;
}
```
\ No newline at end of file
......@@ -112,8 +112,6 @@ The sensor driver model also provides certain driver development APIs that need
| void ReadSensorData(void) | Reads sensor data.|
For details about the interface implementation, see "How to Develop" below.
### How to Develop
1. Develop the acceleration sensor abstract driver. Specifically, implement the **Bind**, **Init**, **Release**, and **Dispatch** functions.
......
......@@ -50,17 +50,17 @@ Based on the attributes of the pins, interfaces on the touchscreens can be class
The interfaces shown in the figure are described as follows:
1. **Power interfaces**
- **Power interfaces**
- LDO\_1P8: 1.8 V digital circuits
- LDO\_3P3: 3.3 V analog circuits
Generally, the touchscreen driver IC is separated from the LCD driver IC. In this case, the touchscreen driver IC requires both 1.8 V and 3.3 V power supplies. Nowadays, the touchscreen driver IC and LCD driver IC can be integrated. Therefore, the touchscreen, requires only the 1.8 V power supply, and the 3.3 V power required internally is supplied by the LCD VSP power \(typical value: 5.5 V\) in the driver IC.
2. **I/O control interfaces**
- **I/O control interfaces**
- RESET: reset pin, which is used to reset the driver IC on the host when suspending or resuming the system.
- INT: interrupt pin, which needs to be set to the input direction and pull-up status during driver initialization. After detecting an external touch signal, the driver triggers the interrupt by operating the interrupt pin. The driver reads the touch reporting data in the ISR function.
3. **Communications interfaces**
- **Communications interfaces**
- I2C: Since only a small amount of touch data is reported by the touchscreen, I2C is used to transmit the reported data. For details about the I2C protocol and interfaces, see [I2C](driver-platform-i2c-des.md#section5361140416).
- SPI: In addition to touch reporting data coordinates, some vendors need to obtain basic capacitance data. Therefore, Serial Peripheral Interface \(SPI\) is used to transmit such huge amount of data. For details about the SPI protocol and interfaces, see [SPI](driver-platform-spi-des.md#section193356154511).
......
......@@ -2,11 +2,11 @@
## Overview<a name="section1"></a>
- An analog-to-digital converter (ADC) is a device that converts analog signals into digital signals.
An analog-to-digital converter (ADC) is a device that converts analog signals into digital signals.
- The ADC APIs provide a set of common functions for ADC data transfer, including:
- Opening or closing an ADC device
- Obtaining the analog-to-digital (AD) conversion result
The ADC APIs provide a set of common functions for ADC data transfer, including:
- Opening or closing an ADC device
- Obtaining the analog-to-digital (AD) conversion result
**Figure 1** ADC physical connection<a name="fig1"></a>
......
......@@ -87,13 +87,10 @@ The ADC module adaptation involves the following steps:
- Initialize **AdcDevice**.
- Instantiate **AdcMethod** in the **AdcDevice** object.
>![](../public_sys-resources/icon-note.gif) **NOTE**
For details, see [Available APIs](#available-apis).
>For details, see [Available APIs](#available-apis).
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether the signal collection is successful.
4. \(Optional\) Debug the driver.
For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether the signal collection is successful.
## Development Example<a name="section1745221471165048"></a>
......@@ -415,6 +412,3 @@ The following uses **adc\_hi35xx.c** as an example to present the contents tha
}
return
```
\ No newline at end of file
......@@ -42,7 +42,8 @@ The DAC module is divided into the following layers:
- The core layer provides the capabilities of binding, initializing, and releasing devices.
- The adaptation layer implements other functions.
![](../public_sys-resources/icon-note.gif)NOTE<br/>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
**Figure 1** Unified service mode
......
......@@ -36,7 +36,8 @@ The DAC module is divided into the following layers:
- The core layer provides the capabilities of binding, initializing, and releasing devices.
- The adaptation layer implements other functions.
![](../public_sys-resources/icon-note.gif)NOTE<br/>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer.
**Figure 1** Unified service mode<a name="fig14423182615525"></a>
......@@ -283,8 +284,8 @@ The DAC module adaptation procedure is as follows:
};
```
![](../public_sys-resources/icon-note.gif) **NOTE**<br/>
For details about **DacMethod**, see [Available APIs](#available-apis).
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>For details about **DacMethod**, see [Available APIs](#available-apis).
- **Init** function
......@@ -466,5 +467,3 @@ The DAC module adaptation procedure is as follows:
4. Debug the driver.
(Optional) Verify the basic functions of the new driver, for example, whether the test cases are successful after the driver is loaded.
\ No newline at end of file
......@@ -75,7 +75,7 @@ The GPIO APIs define a set of standard functions for performing operations on GP
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section259614242196"></a>
......@@ -546,4 +546,3 @@ static int32_t TestCaseGpioIrqEdge(void)
return (g_irqCnt > 0) ? HDF_SUCCESS : HDF_FAILURE;
}
```
\ No newline at end of file
......@@ -163,12 +163,10 @@ The GPIO module adaptation involves the following steps:
- Initialize **GpioCntlr**.
- Instantiate **GpioMethod** in the **GpioCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>For details, see [Available APIs](#section752964871810).
For details, see [Available APIs](#section752964871810).
4. Debug the driver.
- \(Optional\) For new drivers, verify the basic functions, such as the GPIO control status and response to interrupts.
4. \(Optional\) Debug the driver.
For new drivers, verify the basic functions, such as the GPIO control status and response to interrupts.
## Development Example<a name="section800425816103451"></a>
......@@ -422,7 +420,3 @@ The following uses **gpio\_hi35xx.c** as an example to present the contents th
pl061->regBase = NULL;
}
```
\ No newline at end of file
......@@ -5,15 +5,15 @@
### HDMI
- High-definition multimedia interface (HDMI) is an interface for transmitting audio and video data from a source device, such as a DVD player or set-top box (STB), to a sink device, such as a TV or display.
- HDMI works in master/slave mode and usually has a source and a sink.
- The HDMI APIs provide a set of common functions for HDMI transmission, including:
- Opening and closing an HDMI controller
- Starting and stopping HDMI transmission
- Setting audio, video, and High Dynamic Range (HDR) attributes, color depth, and AV mute
- Reading the raw Extended Display Identification Data (EDID) from a sink
- Registering and unregistering a callback for HDMI hot plug detect (HPD).
High-definition multimedia interface (HDMI) is an interface for transmitting audio and video data from a source device, such as a DVD player or set-top box (STB), to a sink device, such as a TV or display.
HDMI works in primary/secondary mode and usually has a source and a sink.
The HDMI APIs provide a set of common functions for HDMI transmission, including:
- Opening and closing an HDMI controller
- Starting and stopping HDMI transmission
- Setting audio, video, and High Dynamic Range (HDR) attributes, color depth, and AV mute
- Reading the raw Extended Display Identification Data (EDID) from a sink
- Registering and unregistering a callback for HDMI hot plug detect (HPD).
### Basic Concepts
......
......@@ -149,7 +149,7 @@ The HDMI module adaptation involves the following steps:
.Bind = HdmiAdapterBind,
.Init = HdmiAdapterInit,
.Release = HdmiAdapterRelease,
.moduleName = "adapter_hdmi_driver",// (mandatory) The value must be the same as that in the .hcs file.
.moduleName = "adapter_hdmi_driver",// (Mandatory) The value must be the same as that in the .hcs file.
};
HDF_INIT(g_hdmiDriverEntry); // Call HDF_INIT to register the driver entry with the HDF.
```
......
......@@ -68,13 +68,11 @@ The I2C module adaptation involves the following steps:
- Initialize **I2cCntlr**.
- Instantiate **I2cMethod** and **I2cLockMethod** in **I2cCntlr**.
>![](../public_sys-resources/icon-note.gif) **NOTE**
For details, see [Available APIs](#available-apis).
>For details, see [Available APIs](#available-apis).
4. \(Optional\) Debug the driver.
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
......@@ -395,6 +393,3 @@ The following uses **i2c\_hi35xx.c** as an example to present the contents tha
return;
}
```
\ No newline at end of file
......@@ -52,7 +52,9 @@ The I3C module adaptation involves the following steps:
3. Instantiate the I3C controller object.
- Initialize **I3cCntlr**.
- Instantiate **I3cMethod** in **I3cCntlr**. For details, see [Available APIs](#available-apis).
- Instantiate **I3cMethod** in **I3cCntlr**.
For details, see [Available APIs](#available-apis).
4. Register an interrupt handler.
Register an interrupt handler for the controller to implement the device hot-join and in-band interrupt (IBI) features.
......
# MIPI CSI<a name="EN-US_TOPIC_0000001198067744"></a>
- [Overview](#section72226945170128)
- [Available APIs](#section735525713405)
- [How to Develop](#section378858277170128)
- [Development Example](#section2049027816170128)
## Overview<a name="section72226945170128"></a>
Defined by the Mobile Industry Processor Interface \(MIPI\) Alliance, the Camera Serial Interface \(CSI\) is a specification that allows data to be transmitted from the camera to the host processor on mobile platforms. In the Hardware Driver Foundation \(HDF\), the MIPI CSI module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS that does not distinguish the user mode and the kernel mode. In the service-free mode, DevHandle \(a void pointer\) directly points to the kernel-mode address of the device object.
......@@ -213,12 +208,10 @@ The MIPI CSI module adaptation involves the following steps:
- Initialize **MipiCsiCntlr**.
- Instantiate **MipiCsiCntlrMethod** in the **MipiCsiCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>For details, see [Available APIs](#available-apis).
For details, see [Available APIs](#available-apis).
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
4. \(Optional\) Debug the driver.
For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
## Development Example<a name="section2049027816170128"></a>
......@@ -408,9 +401,9 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
HDF_LOGI("%s: enter!", __func__);
g_mipiCsi.priv = NULL; // g_mipiTx is a global variable defined.
//static struct MipiCsiCntlr g_mipiCsi = {
//.devNo = 0
//};
// static struct MipiCsiCntlr g_mipiCsi = {
// .devNo = 0
// };
g_mipiCsi.ops = &g_method; // Connect to the MipiCsiCntlrMethod instance.
#ifdef CONFIG_HI_PROC_SHOW_SUPPORT
g_mipiCsi.debugs = &g_debugMethod;
......@@ -484,7 +477,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
struct MipiCsiCntlr *cntlr = NULL;
...
cntlr = MipiCsiCntlrFromDevice(device); // A forced conversion from HdfDeviceObject to MipiCsiCntlr is involved.
//return (device == NULL) ? NULL : (struct MipiCsiCntlr *)device->service;
// return (device == NULL) ? NULL : (struct MipiCsiCntlr *)device->service;
...
OsalSpinDestroy(&cntlr->ctxLock);
......@@ -498,6 +491,3 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the content
HDF_LOGI("%s: unload mipi csi driver success!", __func__);
}
```
\ No newline at end of file
......@@ -2,10 +2,10 @@
## Overview<a name="section16806142183217"></a>
- The Display Serial Interface \(DSI\) is a specification stipulated by the Mobile Industry Processor Interface \(MIPI\) Alliance, aiming to reduce the cost of display controllers in a mobile device. It defines a serial bus and communication protocol among the host, the source of image data, and the target device. In this way, the DSI can send pixel data or commands to peripherals \(usually LCDs or similar display devices\) in serial mode, or reads information such as status and pixel from the peripherals.
The Display Serial Interface \(DSI\) is a specification stipulated by the Mobile Industry Processor Interface \(MIPI\) Alliance, aiming to reduce the cost of display controllers in a mobile device. It defines a serial bus and communication protocol among the host, the source of image data, and the target device. In this way, the DSI can send pixel data or commands to peripherals \(usually LCDs or similar display devices\) in serial mode, or reads information such as status and pixel from the peripherals.
- MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP\) mode. All data lanes can only travel from the DSI host to a peripheral in HS mode, except the first data lane, which can also receive data such as status information and pixels from the peripheral in LP mode. The clock lane is dedicated to transmitting synchronization clock signals in HS mode.
- [Figure 1](#fig1122611461203) shows a simplified DSI interface. Conceptually, a DSI-compliant interface has the same features as interfaces complying with DBI-2 and DPI-2 standards. It sends pixels or commands to a peripheral and can read status or pixel information from the peripheral. The main difference is that the DSI serializes all pixel data, commands, and events that, in traditional interfaces, are conveyed to and from the peripheral on a parallel data bus with additional control signals.
MIPI DSI is capable of working in both high speed \(HS\) mode and low power \(LP\) mode. All data lanes can only travel from the DSI host to a peripheral in HS mode, except the first data lane, which can also receive data such as status information and pixels from the peripheral in LP mode. The clock lane is dedicated to transmitting synchronization clock signals in HS mode.
[Figure 1](#fig1122611461203) shows a simplified DSI interface. Conceptually, a DSI-compliant interface has the same features as interfaces complying with DBI-2 and DPI-2 standards. It sends pixels or commands to a peripheral and can read status or pixel information from the peripheral. The main difference is that the DSI serializes all pixel data, commands, and events that, in traditional interfaces, are conveyed to and from the peripheral on a parallel data bus with additional control signals.
**Figure 1** DSI transmitting and receiving interface<a name="fig1122611461203"></a>
![](figures/dsi-transmitting-and-receiving-interface.png "dsi-transmitting-and-receiving-interface")
......@@ -75,7 +75,7 @@
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All functions described in this document can be called only in kernel space.
## Usage Guidelines<a name="section037231715335"></a>
......@@ -537,4 +537,3 @@ void PalMipiDsiTestSample(void)
MipiDsiClose(handle);
}
```
\ No newline at end of file
......@@ -116,13 +116,10 @@ The MIPI DSI module adaptation involves the following steps:
- Initialize **MipiDsiCntlr**.
- Instantiate **MipiDsiCntlrMethod** in the **MipiDsiCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE**
For details, see [Available APIs](#available-apis).
>For details, see [Available APIs](#available-apis).
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
4. \(Optional\) Debug the driver.
For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
......@@ -273,9 +270,9 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content
{
int32_t ret;
g_mipiTx.priv = NULL; // g_mipiTx is a global variable.
//static struct MipiDsiCntlr g_mipiTx {
// static struct MipiDsiCntlr g_mipiTx {
// .devNo=0
//};
// };
g_mipiTx.ops = &g_method;// Connect to the MipiDsiCntlrMethod instance.
ret = MipiDsiRegisterCntlr(&g_mipiTx, device);// (Mandatory) Call the function at the core layer and g_mipiTx to initialize global variables at the core layer.
...
......@@ -332,6 +329,3 @@ The following uses **mipi\_tx\_hi35xx.c** as an example to present the content
HDF_LOGI("%s: unload mipi_tx driver 1212!", __func__);
}
```
\ No newline at end of file
......@@ -207,13 +207,10 @@ The MMC module adaptation involves the following steps:
- Initialize **MmcCntlr**.
- Instantiate **MmcCntlrOps** in the **MmcCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE**
For details, see [Available APIs](#available-apis).
>For details, see [Available APIs](#available-apis).
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the mount operation and whether the device starts successfully.
4. \(Optional\) Debug the driver.
For new drivers, verify basic functions, for example, verify the information returned after the mount operation and whether the device starts successfully.
## Development Example<a name="section1220893490162704"></a>
......@@ -551,6 +548,3 @@ The following uses **himci.c** as an example to present the contents that need
HimciDeleteHost((struct HimciHost *)cntlr->priv);// Memory release function customized by the vendor. A forced conversion from MmcCntlr to HimciHost is involved in the process.
}
```
\ No newline at end of file
......@@ -5,12 +5,12 @@
### Pin<a name="section2"></a>
- The pin, also called pin controller, manages pin resources of system on a chip (SoC) vendors and provides the pin multiplexing function.
- The pin module defines a set of common methods for managing pins, including:
The pin module, also called pin controller, manages pin resources of system on a chip (SoC) vendors and provides the pin multiplexing function.
The module defines a set of common methods for managing pins, including:
- Obtaining or releasing the pin description handle: The kernel compares the pin name passed in with the pin names of each controller in the linked list. If a match is found, a pin description handle is obtained. After the operation on the pin is complete, the pin description handle will be released.
- Setting or obtaining the pull type of a pin: The pull type can be pull-up, pull-down, or floating.
- Setting or obtaining the pull strength of a pin: You can set the pull strength as required.
- Setting or obtaining the functions of a pin to implement pin multiplexing
- Setting or obtaining the pull type of a pin: The pull type can be pull-up, pull-down, or floating.
- Setting or obtaining the pull strength of a pin: You can set the pull strength as required.
- Setting or obtaining the functions of a pin to implement pin multiplexing
### Basic Concepts<a name="section3"></a>
Pin, as a software concept, provides APIs for uniformly managing the pins from different SoC vendors, providing the pin multiplexing function, and configuring the electrical features of pins.
......
......@@ -79,13 +79,10 @@ The PWM module adaptation involves the following steps:
- Initialize **PwmDev**.
- Instantiate **PwmMethod** in the **PwmDev** object.
>![](../public_sys-resources/icon-note.gif) **NOTE**
For details, see [Available APIs](#available-apis).
>For details, see [Available APIs](#available-apis).
4. Debug the driver.
- \(Optional\) For new drivers, verify the basic functions, such as the PWM control status and response to interrupts.
4. \(Optional\) Debug the driver.
For new drivers, verify the basic functions, such as the PWM control status and response to interrupts.
## Development Example<a name="section1883877829164144"></a>
......@@ -341,6 +338,3 @@ The following uses **pwm\_hi35xx.c** as an example to present the contents tha
HiPwmRemove(hp); //Release HiPwm.
}
```
\ No newline at end of file
......@@ -341,8 +341,6 @@ The regulator module adaptation procedure is as follows:
}
```
4. Debug the driver.
(Optional) Verify the basic functions of the new driver, for example, whether the test cases are successful after the driver is loaded.
4. (Optional) Debug the driver.
Verify the basic functions of the new driver, for example, whether the test cases are successful after the driver is loaded.
\ No newline at end of file
......@@ -95,7 +95,7 @@ The real-time clock \(RTC\) driver provides precise real time for the operating
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section20636145604113"></a>
......@@ -113,7 +113,7 @@ During the OS startup, the HDF loads the RTC driver based on the configuration f
After the RTC driver is loaded, you can use the API provided by the HDF and call APIs of the RTC driver.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>Currently, only one RTC device is supported in the OS.
DevHandle RtcOpen\(void\);
......@@ -354,7 +354,7 @@ int32\_t RtcWriteTime\(DevHandle handle, struct RtcTime \*time\);
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>The RTC start time is 1970/01/01 Thursday 00:00:00 \(UTC\). The maximum value of **year** must be set based on the requirements specified in the product manual of the in-use component. You do not need to configure the day of the week.
```
......@@ -481,7 +481,7 @@ int32\_t RtcWriteAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>The RTC start time is 1970/01/01 Thursday 00:00:00 \(UTC\). The maximum value of **year** must be set based on the requirements specified in the product manual of the in-use component. You do not need to configure the day of the week.
```
......@@ -927,4 +927,3 @@ void RtcTestSample(void)
RtcClose(handle);
}
```
\ No newline at end of file
......@@ -194,13 +194,11 @@ The RTC module adaptation involves the following steps:
- Initialize **RtcHost**.
- Instantiate **RtcMethod** in the **RtcHost** object.
>![](../public_sys-resources/icon-note.gif) **NOTE**
For details, see [Available APIs](#available-apis).
>For details, see [Available APIs](#available-apis).
4. \(Optional\) Debug the driver.
4. Debug the driver.
- \(Optional\) For new drivers, verify the basic functions, such as the RTC control status and response to interrupts.
For new drivers, verify the basic functions, such as the RTC control status and response to interrupts.
## Development Example<a name="section1594883301142407"></a>
......@@ -463,6 +461,3 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents tha
RtcHostDestroy(host); // Release RtcHost.
}
```
\ No newline at end of file
......@@ -2,21 +2,21 @@
## Overview<a name="section193356154511"></a>
- Serial Peripheral Interface \(SPI\) is a serial bus specification used for high-speed, full-duplex, and synchronous communication.
- SPI is developed by Motorola. It is commonly used for communication with flash memory, real-time clocks, sensors, and analog-to-digital \(A/D\) converters.
- SPI works in controller/device mode. Generally, there is one SPI controller that controls one or more SPI devices. They are connected via four wires:
- SCLK: clock signals output from the SPI controller
- MOSI: data output from the SPI controller and input into an SPI device
- MISO: data output from an SPI device and input into the SPI controller
- CS: signals enabled by an SPI device and controlled by the SPI controller
Serial Peripheral Interface \(SPI\) is a serial bus specification used for high-speed, full-duplex, and synchronous communication.
SPI is developed by Motorola. It is commonly used for communication with flash memory, real-time clocks, sensors, and analog-to-digital \(A/D\) converters.
SPI works in controller/device mode. Generally, there is one SPI controller that controls one or more SPI devices. They are connected via four wires:
- SCLK: clock signals output from the SPI controller
- MOSI: data output from the SPI controller and input into an SPI device
- MISO: data output from an SPI device and input into the SPI controller
- CS: signals enabled by an SPI device and controlled by the SPI controller
- [Figure 1](#fig89085710359) shows the connection between one SPI controller and two SPI devices \(device A and device B\). In this figure, device A and device B share three pins \(SCLK, MISO, and MOSI\) of the controller. CS0 of device A and CS1 of device B are connected to CS0 and CS1 of the controller, respectively.
[Figure 1](#fig89085710359) shows the connection between one SPI controller and two SPI devices \(device A and device B\). In this figure, device A and device B share three pins \(SCLK, MISO, and MOSI\) of the controller. CS0 of device A and CS1 of device B are connected to CS0 and CS1 of the controller, respectively.
**Figure 1** SPI controller/device connection<a name="fig89085710359"></a>
![](figures/spi-controller-device-connection.png "spi-controller-device-connection")
- SPI communication is usually initiated by the SPI controller and is operated as follows:
SPI communication is usually initiated by the SPI controller and is operated as follows:
1. A single SPI device is selected at a time via the CS to communicate with the SPI controller.
2. Clock signals are provided for the selected SPI device via the SCLK.
......@@ -36,7 +36,7 @@
- Obtaining and setting SPI device configuration parameters.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>Currently, these functions are only applicable in the communication initiated by the SPI controller.
## Available APIs<a name="section1325964832615"></a>
......@@ -546,4 +546,3 @@ err:
SpiClose(spiHandle);
}
```
\ No newline at end of file
......@@ -102,12 +102,10 @@ The SPI module adaptation involves the following steps:
- Initialize **SpiCntlr**.
- Instantiate **SpiCntlrMethod** in the **SpiCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE**
For details, see [Available APIs](#section752964871810).
>For details, see [Available APIs](#section752964871810).
4. Debug the driver.
- \(Optional\) For new drivers, verify the basic functions, such as the SPI control status and response to interrupts.
4. \(Optional\) Debug the driver.
For new drivers, verify the basic functions, such as the SPI control status and response to interrupts.
## Development Example<a name="section956157227152909"></a>
......@@ -442,7 +440,3 @@ The following uses **spi\_hi35xx.c** as an example to present the contents tha
SpiCntlrDestroy(cntlr); // Release the Pl022 object.
}
```
\ No newline at end of file
......@@ -2,13 +2,13 @@
## Overview<a name="section833012453535"></a>
- The Universal Asynchronous Receiver/Transmitter \(UART\) is a universal serial data bus used for asynchronous communication. It enables bi-directional communication between devices in full-duplex mode.
- UART is widely used to print information for debugging or to connect to various external modules such as GPS and Bluetooth.
- A UART is connected to other modules through two wires \(as shown in [Figure 1](#fig68294715408)\) or four wires \(as shown in [Figure 2](#fig179241542163112)\).
- TX: TX pin of the transmitting UART. It is connected to the RX pin of the peer UART.
- RX: RX pin of the receiving UART. It is connected to the TX pin of the peer UART.
- RTS: Request to Send signal pin. It is connected to the CTS pin of the peer UART and is used to indicate whether the local UART is ready to receive data.
- CTS: Clear to Send signal pin. It is connected to the RTS pin of the peer UART and is used to indicate whether the local UART is allowed to send data to the peer end.
The Universal Asynchronous Receiver/Transmitter \(UART\) is a universal serial data bus used for asynchronous communication. It enables bi-directional communication between devices in full-duplex mode.
UART is widely used to print information for debugging or to connect to various external modules such as GPS and Bluetooth.
A UART is connected to other modules through two wires \(as shown in [Figure 1](#fig68294715408)\) or four wires \(as shown in [Figure 2](#fig179241542163112)\).
- TX: TX pin of the transmitting UART. It is connected to the RX pin of the peer UART.
- RX: RX pin of the receiving UART. It is connected to the TX pin of the peer UART.
- RTS: Request to Send signal pin. It is connected to the CTS pin of the peer UART and is used to indicate whether the local UART is ready to receive data.
- CTS: Clear to Send signal pin. It is connected to the RTS pin of the peer UART and is used to indicate whether the local UART is allowed to send data to the peer end.
**Figure 1** 2-wire UART communication<a name="fig68294715408"></a>
![](figures/2-wire-uart-communication.png "2-wire-uart-communication")
......@@ -17,11 +17,13 @@
![](figures/4-wire-uart-communication.png "4-wire-uart-communication")
- The transmitting and receiving UARTs must ensure that they have the same settings on particular attributes such as the baud rate and data format \(start bit, data bit, parity bit, and stop bit\) before they start to communicate. During data transmission, a UART sends data to the peer end over the TX pin and receives data from the peer end over the RX pin. When the size of the buffer used by a UART for storing received data reaches the preset threshold, the RTS signal of the UART changes to **1** \(data cannot be received\), and the peer UART stops sending data to it because its CTS signal does not allow it to send data.
- The UART interface defines a set of common functions for operating a UART port, including obtaining and releasing device handles, reading and writing data of a specified length, and obtaining and setting the baud rate, as well as the device attributes.
The transmitting and receiving UARTs must ensure that they have the same settings on particular attributes such as the baud rate and data format \(start bit, data bit, parity bit, and stop bit\) before they start to communicate. During data transmission, a UART sends data to the peer end over the TX pin and receives data from the peer end over the RX pin. When the size of the buffer used by a UART for storing received data reaches the preset threshold, the RTS signal of the UART changes to **1** \(data cannot be received\), and the peer UART stops sending data to it because its CTS signal does not allow it to send data.
## Available APIs<a name="section1928742202715"></a>
The UART interface defines a set of common functions for operating a UART port, including obtaining and releasing device handles, reading and writing data of a specified length, and obtaining and setting the baud rate, as well as the device attributes.
**Table 1** APIs for the UART driver
<a name="table1731550155318"></a>
......@@ -94,7 +96,7 @@
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All functions provided in this document can be called only in kernel space.
## Usage Guidelines<a name="section12779050105412"></a>
......@@ -656,4 +658,3 @@ _ERR:
UartClose(handle);
}
```
\ No newline at end of file
......@@ -178,13 +178,11 @@ The UART module adaptation involves the following steps:
- Initialize **UartHost**.
- Instantiate **UartHostMethod** in the **UartHost** object.
>![](../public_sys-resources/icon-note.gif) **NOTE**
For details, see [Available APIs](#available-apis).
>For details, see [Available APIs](#available-apis).
4. \(Optional\) Debug the driver.
4. Debug the driver.
- \(Optional\) For new drivers, verify the basic functions, such as the UART control status and response to interrupts.
For new drivers, verify the basic functions, such as the UART control status and response to interrupts.
## Development Example<a name="section774610224154520"></a>
......@@ -314,7 +312,7 @@ The following uses **uart\_hi35xx.c** as an example to present the contents th
#define UART_FLG_RD_BLOCK (1 << 2)
RecvNotify recv; // Pointer to the function that receives serial port data
struct UartOps *ops; // Custom function pointer structure. For details, see device/hisilicon/drivers/uart/uart_pl011.c.
void *private; // It stores the pointer to the start address of UartPl011Port for easy invocation.
void *private; // Pointer to the start address of UartPl011Port for easy invocation
};
// UartHost is the controller structure at the core layer. Its members are assigned with values by using the Init function.
......@@ -545,6 +543,3 @@ The following uses **uart\_hi35xx.c** as an example to present the contents th
host->priv = NULL;
}
```
\ No newline at end of file
......@@ -70,7 +70,7 @@ A watchdog, also called a watchdog timer, is a hardware timing device. If an err
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All watchdog functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section10103184312813"></a>
......@@ -536,4 +536,3 @@ static int32_t TestCaseWatchdog(void)
return -1;
}
```
\ No newline at end of file
......@@ -127,13 +127,11 @@ The Watchdog module adaptation involves the following steps:
- Initialize **WatchdogCntlr**.
- Instantiate **WatchdogMethod** in the **WatchdogCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE**
For details, see [Available APIs](#available-apis).
>For details, see [Available APIs](#available-apis).
4. \(Optional\) Debug the driver.
4. Debug the driver.
- \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether the watchdog timer is successfully set.
For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether the watchdog timer is successfully set.
## Development Example<a name="section1832270347160117"></a>
......@@ -358,6 +356,3 @@ The following uses **watchdog\_hi35xx.c** as an example to present the content
OsalMemFree(hwdt); // Release the memory occupied by the vendor-defined objects.
}
```
\ No newline at end of file
......@@ -67,11 +67,11 @@ base/update # Update subsystem repository
**Update subsystem**
update\_app
[update\_app](https://gitee.com/openharmony/update_app)
update\_updateservice
[update\_updateservice](https://gitee.com/openharmony/update_updateservice)
update\_updater
[update\_updater](https://gitee.com/openharmony/update_updater)
update\_packaging\_tools
[update\_packaging\_tools](https://gitee.com/openharmony/update_packaging_tools)
......@@ -11,7 +11,7 @@
**FA模型** 只有app/Context中的方法属于FA模型对应的Context。该模式下,应用级别的Context和Ability级别的Context都是该类型的实例,如果在应用级别的Context里面调用了Ability级别的方法,会产生错误。所以开发者需要注意context实例所代表的实际含义。
**Stage模型** 除了app/Context之外的Context都属于Stage模型,分别有application/Context、application/AbilityStageContext、application/ExtensionContext、application/AbilityContext、application/FormExtensionContext和application/ServiceExtensionContext六种Context。这些Context的介绍及使用方式将会在[Stage模型和Context详细介绍](#stage模型和context详细介绍)种进行说明。
**Stage模型** 除了app/Context之外的Context都属于Stage模型,分别有application/Context、application/ApplicationContext、application/AbilityStageContext、application/ExtensionContext、application/AbilityContext、application/FormExtensionContext和application/ServiceExtensionContext七种Context。这些Context的介绍及使用方式将会在[Stage模型和Context详细介绍](#stage模型和context详细介绍)种进行说明。
![contextIntroduction](figures/contextIntroduction.png)
......@@ -55,13 +55,13 @@ export default {
## Stage模型和Context详细介绍
​ Stage模型有6大Context:
​ Stage模型有7大Context:
### application/Context
**概述**
​ application/Context类型的Context是基类Context,里面提供了应用的一些基础信息:resourceManager、applicationInfo、cacheDir等,还有应用的一些基本方法:createBundleContext、switchArea等。应用级别的Context也是application/Context这种类型
​ application/Context类型的Context是基类Context,里面提供了应用的一些基础信息:resourceManager、applicationInfo、cacheDir、area等,还有应用的一些基本方法:createBundleContext等
**获取方法**
......@@ -89,15 +89,77 @@ export default class MainAbility extends Ability {
​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/Context.d.ts
### application/ApplicationContext
**概述**
​ application/ApplicationContext是应用级别的Context。和基类Context相比,应用级别的Context中提供了监听进程内组件的生命周期的能力,包括registerAbilityLifecycleCallback和unregisterAbilityLifecycleCallback两种方法。
**获取方法**
​ 在Ability中通过context.getApplicationContext()方法获取。
**示例**
```javascript
import AbilityStage from "@ohos.application.AbilityStage";
var lifecycleid;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
let AbilityLifecycleCallback = {
onAbilityCreate(ability){
console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability));
},
onAbilityWindowStageCreate(ability){
console.log("AbilityLifecycleCallback onAbilityWindowStageCreate ability:" + JSON.stringify(ability));
},
onAbilityWindowStageDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityWindowStageDestroy ability:" + JSON.stringify(ability));
},
onAbilityDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability));
},
onAbilityForeground(ability){
console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability));
},
onAbilityBackground(ability){
console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability));
},
onAbilityContinue(ability){
console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability));
}
}
// 1.通过context属性获取applicationContext
let applicationContext = this.context.getApplicationContext();
// 2.通过applicationContext注册监听应用内生命周期
lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
}
onDestroy() {
let applicationContext = this.context.getApplicationContext();
applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => {
console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
});
}
}
```
**d.ts声明**
​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ApplicationContext.d.ts
### application/AbilityStageContext
**概述**
**概述**
​ application/AbilityStageContext是Hap包级别的Context。和基类Context相比,Hap包级别的Context中多了HapModuleInfo和Configuration两个信息。
**获取方法**
​ 可以直接在AbilityStage中通过context属性拿到
​ 可以直接在AbilityStage中通过context属性获取
**示例**
......@@ -116,7 +178,7 @@ export default class MyAbilityStage extends AbilityStage {
### application/AbilityContext
**概述**
**概述**
​ Stage模型下,每个Ability中都包含了一个Context属性。
......@@ -124,7 +186,7 @@ export default class MyAbilityStage extends AbilityStage {
**获取方法**
​ 在Ability中通过context属性拿到
​ 在Ability中通过context属性获取
**示例**
......@@ -158,7 +220,7 @@ export default class MainAbility extends Ability {
### application/ExtensionContext
**概述**
**概述**
​ 和FA模型不同的是,Stage模型把Service从Ability中剥离出来,单独定义了一组通用扩展类Extension用来处理等同的功能。Extension是一个基类,不承担具体业务功能。业务方根据自己的需要去扩展对应的Extension,例如:ServiceAbility扩展为了ServiceExtensionAbility,卡片扩展为了FormExtension。
......@@ -174,7 +236,7 @@ export default class MainAbility extends Ability {
### application/ServiceExtensionContext
**概述**
**概述**
​ ServiceExtensionAbility类似于FA模型的ServiceAbility,里面只有生命周期回调相关的处理。
......@@ -213,18 +275,11 @@ export default class ServiceExtAbility extends ServiceExtensionAbility {
```
**d.ts声明**
​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ServiceExtensionContext.d.ts
### application/FormExtensionContext
[FormExtensionContext](/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md)
**d.ts声明**
​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/FormExtensionContext.d.ts
## 常见问题
**通过globalThis去获取Context**
......
......@@ -210,6 +210,7 @@ Form需要在应用配置文件config.json中进行配置。
let formName = want.parameters["ohos.extra.param.key.form_name"];
let tempFlag = want.parameters["ohos.extra.param.key.form_temporary"];
// 由开发人员自行实现,将创建的卡片信息持久化,以便在下次获取/更新该卡片实例时进行使用
// storeFormInfo 接口未在此处实现,具体实现请参考:相关实例 章节中的 FormAbility FA模型卡片 实例
storeFormInfo(formId, formName, tempFlag, want);
let obj = {
......@@ -225,9 +226,11 @@ Form需要在应用配置文件config.json中进行配置。
```javascript
onDestroy(formId) {
// 删除卡片实例数据
deleteFormInfo(formId);
console.log('FormAbility onDestroy');
// 由开发人员自行实现,删除之前持久化的卡片实例数据
// deleteFormInfo 接口未在此处实现,具体实现请参考:相关实例 章节中的 FormAbility FA模型卡片 实例
deleteFormInfo(formId);
}
```
......
......@@ -223,6 +223,7 @@ Form需要在应用配置文件module.json中进行配置。
let formName = want.parameters["ohos.extra.param.key.form_name"];
let tempFlag = want.parameters["ohos.extra.param.key.form_temporary"];
// 由开发人员自行实现,将创建的卡片信息持久化,以便在下次获取/更新该卡片实例时进行使用
// storeFormInfo 接口未在此处实现,具体实现请参考:相关实例 章节中的 FormExtAbility Stage模型卡片 实例
storeFormInfo(formId, formName, tempFlag, want);
let obj = {
......@@ -238,9 +239,11 @@ Form需要在应用配置文件module.json中进行配置。
```javascript
onDestroy(formId) {
// 删除卡片实例数据
deleteFormInfo(formId);
console.log('FormAbility onDestroy');
// 由开发人员自行实现,删除之前持久化的卡片实例数据
// deleteFormInfo 接口未在此处实现,具体实现请参考:相关实例 章节中的 FormExtAbility Stage模型卡片 实例
deleteFormInfo(formId);
}
```
......
......@@ -10,6 +10,10 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以
详细API含义可参考:[音频管理API文档AudioCapturer](../reference/apis/js-apis-audio.md)
**图1** 音频采集状态机
![](figures/audio-capturer-state.png)
## 开发步骤
1. 使用createAudioCapturer()创建一个AudioCapturer实例。
......
......@@ -14,10 +14,16 @@ AudioRenderer提供了渲染音频文件和控制播放的接口,开发者可
在进行应用开发的过程中,建议开发者通过on('stateChange')方法订阅AudioRenderer的状态变更。因为针对AudioRenderer的某些操作,仅在音频播放器在固定状态时才能执行。如果应用在音频播放器处于错误状态时执行操作,系统可能会抛出异常或生成其他未定义的行为。
**图1** 音频渲染状态机
![](figures/audio-renderer-state.png)
### 异步操作
为保证UI线程不被阻塞,大部分AudioRenderer调用都是异步的。对于每个API均提供了callback函数和Promise函数,以下示例均采用Promise函数,更多方式可参考[音频管理API文档AudioRenderer](../reference/apis/js-apis-audio.md#audiorenderer8)
## 开发步骤
1. 使用createAudioRenderer()创建一个AudioRenderer实例。
......
......@@ -11,4 +11,5 @@
- [应用包结构说明(Stage模型)](module-structure.md)
- [资源文件的分类](basic-resource-file-categories.md)
- [SysCap说明](syscap.md)
- [HarmonyAppProvision配置文件](app-provision-structure.md)
......@@ -2,15 +2,19 @@
在应用的开发过程中,应用的部分信息需要在HarmonyAppProvision配置文件(该文件在部分文档中也称为profile文件)中声明。
## 配置文件的内部结构
HarmonyAppProvision文件包含基本信息、validity对象、bundle-info对象、acls对象、permissions对象、debug-info对象等部分组成。
HarmonyAppProvision文件包含version-code对象、version-name对象、uuid对象、type对象、issuer对象、validity对象、bundle-info对象、acls对象、permissions对象、debug-info对象等部分组成。
表1 配置文件内部结构说明
**表1** 配置文件内部结构说明
| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 |
| ----------- | ---------------------------------------------------------------------------------------- | -------- | -------- | -------- |
| 基本信息 | 表示HarmonyAppProvision文件的基本信息。参考[基本信息内部结构](#基本信息内部结构)。 | 对象 | 必选 | 不可缺省 |
| version-code | 表示HarmonyAppProvision文件格式的版本号,取值范围为二进制32位以内的正整数。 | 数值 | 必选 | 不可缺省 |
| version-name | 表示版本号的文字描述,推荐使用三段数字版本号,如A.B.C。 | 字符串 | 必选 | 不可缺省 |
| uuid | 表示文件的唯一ID号,用于OEM厂商标识HarmonyAppProvision文件,开源社区版本该属性不做强制要求。 | 字符串 | 必选 | 不可缺省 |
| type | 表示HarmonyAppProvision文件的类型, 系统预定义的文件类型包括:debug(用于应用发布场景) ,开源社区版本该属性值建议为debug。 | 字符串 | 必选 | 不可缺省 |
| issuer | 表示HarmonyAPPProvision签发者。 | 字符串 | 必选 | 不可缺省 |
| validity | 表示HarmonyAppProvision文件有效期的信息。参考[validity对象内部结构](#validity对象内部结构)。 | 对象 | 必选 | 不可缺省 |
| bundle-info | 表示应用包以及开发者的信息。参考[bundle-info对象内部结构](#bundle-info对象内部结构)。 | 对象 | 必选 | 不可缺省 |
| acls | 表示授权的应用权限信息。参考[acls对象内部结构](#acls对象内部结构)。 | 对象 | 可选 | 不可缺省 |
| acls | 表示授权的acl权限信息。参考[acls对象内部结构](#acls对象内部结构)。 | 对象 | 可选 | 不可缺省 |
| permissions | 表示允许使用的受限敏感权限信息。参考[permissions对象内部结构](#permissions对象内部结构)。 | 对象 | 可选 | 不可缺省 |
| debug-info | 表示应用调试场景下的额外信息。参考[debug-info对象内部结构](#debug-info对象内部结构)。 | 对象 | 可选 | 不可缺省 |
......@@ -47,56 +51,46 @@ HarmonyAppProvision文件示例:
}
```
### 基本信息内部结构
表2 基本信息的内部结构说明
| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 |
| ---------- | ------------------------------------------------------------ | -------- | -------- | ------------------ |
| version-code | 表示HarmonyAppProvision文件格式的版本号,取值范围为二进制32位以内的正整数 | 数值 | 必选 | 不可缺省 |
| version-name | 表示版本号的文字描述,推荐使用三段数字版本号,如A.B.C | 字符串 | 必选 | 不可缺省 |
| uuid | 表示文件的唯一ID号,用于OEM厂商标识HarmonyAppProvision文件,开源社区版本该属性不做强制要求 | 字符串 | 必选 | 不可缺省 |
| type | 表示HarmonyAppProvision文件的类型, 系统预定义的文件类型包括: debug(用于应用调试场景)和release(用于应用发布场景) ,开源社区版本该属性值建议为debug | 字符串 | 必选 | 不可缺省 |
| issuer | 表示HarmonyAppProvision签发者 | 字符串 | 必选 | 不可缺省 |
### validity对象内部结构
表3 validity对象的内部结构
| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 |
| ---------- | ------------------------------- | ------- | ------- | --------- |
| not-before | 表示文件有效期的开始时间,非负整数 | 数值 | 必选 | 不可缺省 |
| not-after | 表示文件有效期的结束时间,非负整数 | 数值 | 必选 | 不可缺省 |
| not-before | 表示文件有效期的开始时间,时间表示方式为unix时间戳,非负整数。 | 数值 | 必选 | 不可缺省 |
| not-after | 表示文件有效期的结束时间,时间表示方式为unix时间戳,非负整数。 | 数值 | 必选 | 不可缺省 |
### bundle-info对象内部结构
表4 bundle-info对象的内部结构
| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 |
| ------------------------ | ------------------------------- | ------- | -------- | --------- |
| developer-id | 表示开发者的唯一ID号,用于OEM厂商标识开发者,开源社区版本该属性不做强制要求 | 字符串 | 必选 | 不可缺省 |
| development-certificate | 表示[调试证书](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/hapsigntool-guidelines.md)的信息 | 数值 | 当type属性为debug时,该属性必选;否则,该属性可选 | 不可缺省 |
| distribution-certificate | 表示[发布证书](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/hapsigntool-guidelines.md)的信息 | 数值 | 当type属性为release时,该标签必选;否则,该标签可选 | 不可缺省 |
| bundle-name | 表示应用程序的包名 | 字符串 | 必选 | 不可缺省 |
| apl | 表示应用程序的[apl级别](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/accesstoken-overview.md),系统预定义的apl包括:normal、system_basic和system_core | 字符串 | 必选 | 不可缺省 |
| app-feature | 表示应用程序的类型,系统预定义的app-feature包括hos_system_app (系统应用)和hos_normal_app(普通应用) | 字符串 | 必选 | 不可缺省 |
| developer-id | 表示开发者的唯一ID号,用于OEM厂商标识开发者,开源社区版本该属性不做强制要求 | 字符串 | 必选 | 不可缺省 |
| development-certificate | 表示[调试证书](../security/hapsigntool-guidelines.md)的信息。 | 数值 | 当type属性为debug时,该属性必选;否则,该属性可选。 | 不可缺省 |
| distribution-certificate | 表示[发布证书](../security/hapsigntool-guidelines.md)的信息。 | 数值 | 当type属性为release时,该标签必选;否则,该标签可选。 | 不可缺省 |
| bundle-name | 表示应用程序的包名 | 字符串 | 必选 | 不可缺省 |
| apl | 表示应用程序的[apl级别](../security/accesstoken-overview.md),系统预定义的apl包括:normal、system_basic和system_core。 | 字符串 | 必选 | 不可缺省 |
| app-feature | 表示应用程序的类型,系统预定义的app-feature包括hos_system_app (系统应用)和hos_normal_app(普通应用) | 字符串 | 必选 | 不可缺省 |
### acls对象内部结构
acls对象包含已授权的acl权限,这类权限通常是指应用安装时即可授权的权限(system_grant权限)。需要指出的是,开发者仍然需要在应用包配置文件([config.json](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/quick-start/package-structure.md))将acls权限信息填写到reqPermissions属性中。
acls对象包含已授权的[acl权限](../security/accesstoken-overview.md)。需要指出的是,开发者仍然需要在应用包配置文件([config.json](package-structure.md))将acls权限信息填写到reqPermissions属性中。
5 acls对象的内部结构
4 acls对象的内部结构
| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 |
| ------------------------ | ------------------------------- | ------- | ------- | --------- |
| allowed-acls | 表示授权的[acl权限](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/accesstoken-overview.md)列表 | 字符串数组 | 可选 | 不可缺省 |
| allowed-acls | 表示已授权的[acl权限](../security/accesstoken-overview.md)列表。 | 字符串数组 | 可选 | 不可缺省 |
### permissions对象内部结构
permissions对象包含允许使用的受限敏感权限;不同于acls对象,permissions对象中的权限仅代表应用允许使用该敏感权限,权限最终由用户运行时授权。需要指出的是,开发者仍然需要在应用包配置文件([config.json](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/quick-start/package-structure.md))将permissions权限信息填写到reqPermissions属性中。
permissions对象包含允许使用的受限敏感权限。不同于acls对象,permissions对象中的权限仅代表应用允许使用该敏感权限,权限最终由用户运行时授权。需要指出的是,开发者仍然需要在应用包配置文件([config.json](package-structure.md))将permissions权限信息填写到reqPermissions属性中。
6 permissions对象的内部结构
5 permissions对象的内部结构
| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 |
| ------------------------ | ------------------------------- | ------- | ------- | --------- |
| restricted-permissions | 表示允许使用的[受限敏感权限](https://gitee.com/openharmony/docs/blob/49108dac7b7f2365f0b67b7315966e7e530f19b1/zh-cn/application-dev/security/accesstoken-overview.md) | 字符串数组 | 可选 | 不可缺省 |
| restricted-permissions | 表示允许使用的[受限敏感权限](../security/accesstoken-overview.md) | 字符串数组 | 可选 | 不可缺省 |
### debug-info对象内部结构
debug-info对象包含应用调试场景下的信息,主要是设备管控的信息。
7 debug-info对象的内部结构
6 debug-info对象的内部结构
| 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 |
| ------------------------ | ------------------------------- | ------- | ------- | --------- |
| device-id-type | 表示设备ID的类型,当前系统仅提供udid的设备ID类型 | 字符串 | 可选 | 不可缺省 |
| device-ids | 表示应用调试场景下允许调试的设备ID列表 | 字符串数组 | 可选 | 不可缺省 |
\ No newline at end of file
| device-id-type | 表示设备ID的类型,当前系统仅提供udid的设备ID类型。 | 字符串 | 可选 | 不可缺省 |
| device-ids | 表示应用调试场景下允许调试的设备ID列表。 | 字符串数组 | 可选 | 不可缺省 |
\ No newline at end of file
......@@ -2,11 +2,11 @@
# 应用包结构配置文件的说明
在开发FA模型下的应用程序时,需要在config.json文件中对应用的包结构进行申明;同样的,在开发stage模型下的应用程序时,需要在module.json配置文件中对应用的包结构进行声明。
在开发FA模型下的应用程序时,需要在config.json文件中对应用的包结构进行申明;同样的,在开发stage模型下的应用程序时,需要在module.json和app.json配置文件中对应用的包结构进行声明。
## 配置文件内部结构
module.json由app和module这两个部分组成,缺一不可。配置文件的内部结构参见表1。
配置文件由app和module这两个部分组成,缺一不可。配置文件的内部结构参见表1。
表1 配置文件的内部结构说明
......@@ -15,7 +15,9 @@ module.json由app和module这两个部分组成,缺一不可。配置文件的
| app | 表示应用的全局配置信息。同一个应用的不同HAP包的app配置必须保持一致。参考[app对象内部结构](#app对象内部结构)。 | 对象 | 否 |
| module | 表示HAP包的配置信息。该标签下的配置只对当前HAP包生效。参考[module对象内部结构](#module对象内部结构)。 | 对象 | 否 |
module.json示例:
### app对象内部结构
app.json示例:
```json
{
......@@ -37,7 +39,37 @@ module.json示例:
"car": {
"apiCompatibleVersion": 8
}
},
}
}
```
该标签为整个应用的属性,影响应用中所有hap及组件。该标签的内部结构参见表2。
表2 app对象的内部结构说明
| 属性名称 | 含义 | 数据类型 | 是否可缺省 |
| ------------------------------ | ------------------------------------------------------------ | -------- | ------------------------------------------- |
| bundleName | 该标签表示应用的包名,用于标识应用的唯一性。该标签不可缺省。标签的值命名规则 :<br /> 1)字符串以字母、数字、下划线和符号”.”组成;<br /> 2)以字母开头;<br /> 3)最小长度7个字节,最大长度127个字节。<br /> 推荐采用反域名形式命名(如 :com.example.xxx,建议第一级为域名后缀com,第二级为厂商/个人名,第三级为应用名,也可以多级)。<br /> 其中,随系统源码编译的应用需命名为”com.ohos.xxx”形式, ohos标识OpenHarmony系统应用。 | 字符串 | 否 |
| debug | 该标签标识应用是否可调试。 | 布尔值 | 该标签可以缺省,缺省为false。 |
| icon | 该标签标识应用的图标,标签值为资源文件的索引。 | 字符串 | 该标签不可缺省。 |
| label | 该标签标识应用的的名称,标签值为资源文件的索引,以支持多语言。 | 字符串 | 该标签不可缺省。 |
| description | 该标签标识App的描述信息,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 |
| vendor | 该标签是对应用开发厂商的描述。该标签的值是字符串类型(最大255个字节)。 | 字符串 | 该标签可以缺省,缺省为空。 |
| versionCode | 该标签标识应用的版本号,该标签值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。开发者可以将该值设置为任何正整数,但是必须确保应用的新版本都使用比旧版本更大的值。该标签不可缺省,versionCode 值应小于2的31方。 | 数值 | 该标签不可缺省 |
| versionName | 该标签标识版本号的文字描述,用于向用户展示。<br />该标签仅由数字和点构成,推荐采用“A.B.C.D”四段式的形式。四段式推荐的含义如下所示。<br/>第一段 :主版本号/Major,范围0-99,重大修改的版本,如实现新的大功能或重大变化。<br/>第二段 :次版本号/Minor,范围0-99,表示实现较突出的特点,如新功能添加和大问题修复。<br/>第三段 :特性版本号/Feature,范围0-99,标识规划的新版本特性。<br/>第四段 :修订版本号/Patch,范围0-999,表示维护版本,修复bug。 | 字符串 | 该标签不可缺省 |
| minCompatibleVersionCode | 该标签标识该app pack能够兼容的最低历史版本号。 | 数值 | 该标签可缺省。缺省值等于versionCode标签值。 |
| minAPIVersion | 该标签标识应用运行需要的API最小版本。 | 数值 | 该标签不可缺省。 |
| targetAPIVersion | 该标签标识应用运行需要的API目标版本。 | 整形 | 该标签不可缺省。 |
| apiReleaseType | 该标签标识应用运行需要的API目标版本的类型,采用字符串类型表示。取值为“CanaryN”、“BetaN”或者“Release”,其中,N代表大于零的整数。<br />Canary :受限发布的版本。<br/>Beta :公开发布的Beta版本。<br/>Release :公开发布的正式版本。 | 字符串 | 该标签可缺省,缺省为“Release”。 |
| distributedNotificationEnabled | 该标签标记该应用是否开启分布式通知。 | 布尔值 | 该标签可缺省,缺省值为true。 |
| entityType | 该标签标记该应用的类别,具体有 :游戏类(game),影音类(media)、社交通信类(communication)、新闻类(news)、出行类(travel)、工具类(utility)、购物类(shopping)、教育类(education)、少儿类(kids)、商务类(business)、拍摄类(photography)。 | 字符串 | 该标签可以缺省,缺省为unspecified。 |
### module对象内部结构
module.json示例:
```json
{
"module": {
"name": "myHapName",
"type": "entry|feature|har",
......@@ -163,31 +195,6 @@ module.json示例:
}
```
### app对象内部结构
该标签为整个应用的属性,影响应用中所有hap及组件。该标签的内部结构参见表2。
表2 app对象的内部结构说明
| 属性名称 | 含义 | 数据类型 | 是否可缺省 |
| ------------------------------ | ------------------------------------------------------------ | -------- | ------------------------------------------- |
| bundleName | 该标签表示应用的包名,用于标识应用的唯一性。该标签不可缺省。标签的值命名规则 :<br /> 1)字符串以字母、数字、下划线和符号”.”组成;<br /> 2)以字母开头;<br /> 3)最小长度7个字节,最大长度127个字节。<br /> 推荐采用反域名形式命名(如 :com.example.xxx,建议第一级为域名后缀com,第二级为厂商/个人名,第三级为应用名,也可以多级)。<br /> 其中,随系统源码编译的应用需命名为”com.ohos.xxx”形式, ohos标识OpenHarmony系统应用。 | 字符串 | 否 |
| debug | 该标签标识应用是否可调试。 | 布尔值 | 该标签可以缺省,缺省为false。 |
| icon | 该标签标识应用的图标,标签值为资源文件的索引。 | 字符串 | 该标签不可缺省。 |
| label | 该标签标识应用的的名称,标签值为资源文件的索引,以支持多语言。 | 字符串 | 该标签不可缺省。 |
| description | 该标签标识App的描述信息,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 |
| vendor | 该标签是对应用开发厂商的描述。该标签的值是字符串类型(最大255个字节)。 | 字符串 | 该标签可以缺省,缺省为空。 |
| versionCode | 该标签标识应用的版本号,该标签值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。开发者可以将该值设置为任何正整数,但是必须确保应用的新版本都使用比旧版本更大的值。该标签不可缺省,versionCode 值应小于2的31方。 | 数值 | 该标签不可缺省 |
| versionName | 该标签标识版本号的文字描述,用于向用户展示。<br />该标签仅由数字和点构成,推荐采用“A.B.C.D”四段式的形式。四段式推荐的含义如下所示。<br/>第一段 :主版本号/Major,范围0-99,重大修改的版本,如实现新的大功能或重大变化。<br/>第二段 :次版本号/Minor,范围0-99,表示实现较突出的特点,如新功能添加和大问题修复。<br/>第三段 :特性版本号/Feature,范围0-99,标识规划的新版本特性。<br/>第四段 :修订版本号/Patch,范围0-999,表示维护版本,修复bug。 | 字符串 | 该标签不可缺省 |
| minCompatibleVersionCode | 该标签标识该app pack能够兼容的最低历史版本号。 | 数值 | 该标签可缺省。缺省值等于versionCode标签值。 |
| minAPIVersion | 该标签标识应用运行需要的API最小版本。 | 数值 | 该标签不可缺省。 |
| targetAPIVersion | 该标签标识应用运行需要的API目标版本。 | 整形 | 该标签不可缺省。 |
| apiReleaseType | 该标签标识应用运行需要的API目标版本的类型,采用字符串类型表示。取值为“CanaryN”、“BetaN”或者“Release”,其中,N代表大于零的整数。<br />Canary :受限发布的版本。<br/>Beta :公开发布的Beta版本。<br/>Release :公开发布的正式版本。 | 字符串 | 该标签可缺省,缺省为“Release”。 |
| distributedNotificationEnabled | 该标签标记该应用是否开启分布式通知。 | 布尔值 | 该标签可缺省,缺省值为true。 |
| entityType | 该标签标记该应用的类别,具体有 :游戏类(game),影音类(media)、社交通信类(communication)、新闻类(news)、出行类(travel)、工具类(utility)、购物类(shopping)、教育类(education)、少儿类(kids)、商务类(business)、拍摄类(photography)。 | 字符串 | 该标签可以缺省,缺省为unspecified。 |
### module对象内部结构
hap包的配置信息,该标签下的配置只对当前hap包生效。
表3 module对象内部结构
......
......@@ -23,11 +23,12 @@ OpenHarmony提供了一套UI开发框架,即方舟开发框架(ArkUI框架
| 类Web开发范式 | JS语言 | 数据驱动更新 | 界面较为简单的程序应用和卡片 | Web前端开发人员 |
| 声明式开发范式 | 扩展的TS语言(eTS) | 数据驱动更新 | 复杂度较大、团队合作度较高的程序 | 移动系统应用开发人员、系统应用开发人员 |
对于DevEco Studio V2.2 Beta1及更高版本,在使用JS语言开发时,除传统代码方式外,还支持使用低代码方式
对于JS语言开发时,低代码方式在DevEco Studio V2.2 Beta1及更高版本中支持
对于eTS语言开发,除传统代码方式外,低代码方式则在DevEco Studio V3.0 Beta3及更高版本中支持。
对于eTS语言开发,低代码方式在DevEco Studio V3.0 Beta3及更高版本中支持。
OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,遵循JS开发规范,通过可视化界面开发方式快速构建布局,可有效降低开发者的上手成本并提升开发者构建UI界面的效率。
更多UI框架的开发内容及指导,请参见[UI开发](../ui/arkui-overview.md)
### Ability
......
......@@ -50,43 +50,43 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
第一个页面内有一个容器、文本和一个按钮,通过Column、Text和Button组件来实现。其中,Column为沿垂直方向布局的容器组件,具体使用请见[Column](../reference/arkui-ts/ts-container-column.md)
1. **删除画布原有模板组件。**<a name="delete_origin_content"></a>
1. 删除画布原有模板组件。<a name="delete_origin_content"></a>
打开index.visual文件,选中画布中的组件,单击鼠标右键,选择Delete删除画布原有模板组件。操作如下所示:
![zh-cn_image_0000001233208980](figures/zh-cn_image_0000001233208980.gif)
2. **添加容器,设置Column容器的样式和属性。**<a name="add_container"></a>
2. 添加容器,设置Column容器的样式和属性。<a name="add_container"></a>
选中UI Control中的Column组件,将其拖至画布。点击右侧属性样式栏中的图标![zh-cn_image_0000001233048996](figures/zh-cn_image_0000001233048996.png)(General),设置Column组件的高度Height为100%,使其占满屏幕;点击右侧属性样式栏中的图标![zh-cn_image_0000001233368860](figures/zh-cn_image_0000001233368860.png)(Feature),设置Column组件的AlignItems样式为center,使得其子组件在水平轴上居中显示。操作如下所示:
![zh-cn_image_0000001277488977](figures/zh-cn_image_0000001277488977.gif)
3. **添加文本。**
3. 添加文本。
选中UI Control中的Text组件,将其拖至画布,再拖至Column组件的中央区域。点击右侧属性样式栏中的图标![zh-cn_image_0000001277608813](figures/zh-cn_image_0000001277608813.png)(Feature),设置Text组件的Content属性为“this.message”(即“Hello World”);设置组件的FontSize样式为30fp,使得其文字放大;设置组件的TextAlign样式为center,使得组件文字居中显示。再选中画布上的Text组件,拖动放大。操作如下所示:
![zh-cn_image_0000001235731706](figures/zh-cn_image_0000001233528156.gif)
4. **添加按钮。**
4. 添加按钮。
选中UI Control中的Button组件,将其拖至画布,再拖至Text组件下面。点击右侧属性样式栏中的图标![zh-cn_image_0000001277728577](figures/zh-cn_image_0000001277728577.png)(General),设置Button组件的Height为40vp;点击右侧属性样式栏中的图标![zh-cn_image_0000001277809337](figures/zh-cn_image_0000001277809337.png)(Feature),设置Button组件的Label属性为“Next”;设置Button组件的FontSize样式为25fp,使得其文字放大。操作如下所示:
![zh-cn_image_0000001235732402](figures/zh-cn_image_0000001233208988.gif)
5. **在编辑窗口右上角的侧边工具栏,点击Previewer,打开预览器。** 第一个页面效果如下图所示:
5. 在编辑窗口右上角的侧边工具栏,点击Previewer,打开预览器。第一个页面效果如下图所示:
![zh-cn_image_0000001235892798](figures/zh-cn_image_0000001233049004.png)
## 构建第二个页面
1. **创建第二个页面。**
1. 创建第二个页面。
在“**Project**”窗口,打开“**entry &gt; src &gt; main &gt; ets &gt; MainAbility**”,右键点击“**pages**”文件夹,选择“**New &gt; Visual**”,命名为“**second**”,单击“**Finish**”,即完成第二个页面的创建。可以看到文件目录结构如下:
![zh-cn_image_0000001233368868](figures/zh-cn_image_0000001233368868.png)
2. **[删除画布原有模板组件。](#delete_origin_content)**
2. [删除画布原有模板组件。](#delete_origin_content)
3. **[添加容器,设置Column容器的样式和属性。](#add_container)**
3. [添加容器,设置Column容器的样式和属性。](#add_container)
4. **添加文本。**
4. 添加文本。
- 在second.ets文件中,将本页面的message文本内容设置为“Hi there”,示例如下:
......@@ -109,7 +109,7 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
![zh-cn_image_0000001280255513](figures/zh-cn_image_0000001277608817.gif)
5. **添加按钮。**
5. 添加按钮。
选中UI Control中的Button组件,将其拖至画布,再拖至Text组件下面。点击右侧属性样式栏中的图标![zh-cn_image_0000001233528160](figures/zh-cn_image_0000001233528160.png)(General),设置Button组件的Height为40vp;点击右侧属性样式栏中的图标![zh-cn_image_0000001277728597](figures/zh-cn_image_0000001277728597.png)(Feature),设置Button组件的Value属性为“Back”;设置组件的FontSize样式为25fp,使得其文字放大。操作如下所示:
![zh-cn_image_0000001280383937](figures/zh-cn_image_0000001277809361.gif)
......@@ -119,7 +119,7 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
页面间的导航可以通过页面路由router来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。
1. **第一个页面跳转到第二个页面。**
1. 第一个页面跳转到第二个页面。
在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。需同时处理ets文件及visual文件。
-**index.ets**”示例如下:
......@@ -150,7 +150,7 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
![zh-cn_image_0000001235745716](figures/zh-cn_image_0000001233049040.png)
2. **第二个页面返回到第一个页面。**
2. 第二个页面返回到第一个页面。
在第二个页面中,返回按钮绑定back方法,点击按钮时返回到第一页。需同时处理ets文件及visual文件。
-**second.ets**”示例如下:
......@@ -180,7 +180,7 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
![zh-cn_image_0000001280385809](figures/zh-cn_image_0000001277489017.png)
3. **打开index.visual或index.ets文件,点击预览器中的** ![zh-cn_image_0000001277608849](figures/zh-cn_image_0000001277608849.png) **按钮进行刷新。** 效果如下图所示:
3. 打开index.visual或index.ets文件,点击预览器中的 ![zh-cn_image_0000001277608849](figures/zh-cn_image_0000001277608849.png) 按钮进行刷新。效果如下图所示:
![zh-cn_image_0000001233528192](figures/zh-cn_image_0000001233528192.png)
......
......@@ -25,9 +25,10 @@
- **src &gt; main &gt; ets** :用于存放ets源码。
- **src &gt; main &gt; ets &gt; MainAbility** :应用/服务的入口。
- **src &gt; main &gt; ets &gt; MainAbility &gt; pages** :MainAbility包含的页面。
- **src &gt; main &gt; ets &gt; MainAbility &gt; pages &gt; index.ets** :pages列表中的第一个页面,即应用的首页入口。
- **src &gt; main &gt; ets &gt; MainAbility &gt; app.ets** :承载Ability生命周期。
- **src &gt; main &gt; resources** :用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。
- **src &gt; main &gt; config.json** :模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。
- **src &gt; main &gt; config.json** :模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[应用包结构配置文件的说明](package-structure.md)
- **build-profile.json5** :当前的模块信息 、编译信息配置项,包括 buildOption target配置等。
- **hvigorfile.js** :模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。
......@@ -38,8 +39,8 @@
## 构建第一个页面
1. **使用文本组件。**
工程同步完成后,在“**Project**”窗口,点击“**entry &gt; src &gt; main &gt; ets &gt; MainAbility &gt; pages**”,打开“**index.ets**”文件,可以看到页面由Text组件组成。“**index.ets**”文件的示例如下:
1. 使用文本组件。
工程同步完成后,在“**Project**”窗口,点击“**entry &gt; src &gt; main &gt; ets &gt; MainAbility &gt; pages**”,打开“**index.ets**”文件,可以看到页面由Text组件组成。“**index.ets**”文件的示例如下:
```
......@@ -62,7 +63,7 @@
}
```
2. **添加按钮。**
2. 添加按钮。
在默认页面基础上,我们添加一个Button组件,作为按钮接收用户点击的动作,从而实现跳转到另一个页面。“**index.ets**”文件的示例如下:
......@@ -99,19 +100,19 @@
}
```
3. **在编辑窗口右上角的侧边工具栏,点击Previewer,打开预览器。** 第一个页面效果如下图所示:
3. 在编辑窗口右上角的侧边工具栏,点击Previewer,打开预览器。第一个页面效果如下图所示:
![zh-cn_image_0000001216239356](figures/zh-cn_image_0000001216239356.png)
## 构建第二个页面
1. **创建第二个页面。**
1. 创建第二个页面。
在“**Project**”窗口,打开“**entry &gt; src &gt; main &gt; ets &gt; MainAbility**”,右键点击“**pages**”文件夹,选择“**New &gt; Page**”,命名为“**second**”,点击“**Finish**”,即完成第二个页面的创建。可以看到文件目录结构如下:
![zh-cn_image_0000001223397122](figures/zh-cn_image_0000001223397122.png)
2. **添加文本及按钮。**
2. 添加文本及按钮。
参照第一个页面,在第二个页面添加Text组件、Button组件等,并设置其样式。“**second.ets**”文件的示例如下:
......@@ -152,7 +153,7 @@
页面间的导航可以通过页面路由router来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。
1. **第一个页面跳转到第二个页面。**
1. 第一个页面跳转到第二个页面。
在第一个页面中,跳转按钮绑定onClick事件,点击按钮时跳转到第二页。“**index.ets**”文件的示例如下:
......@@ -195,7 +196,7 @@
}
```
2. **第二个页面返回到第一个页面。**
2. 第二个页面返回到第一个页面。
在第二个页面中,返回按钮绑定onClick事件,点击按钮时返回到第一页。“**second.ets**”文件的示例如下:
......@@ -237,7 +238,7 @@
}
```
3. **打开index.ets文件,点击预览器中的** ![zh-cn_image_0000001262219043](figures/zh-cn_image_0000001262219043.png) **按钮进行刷新。** 效果如下图所示:
3. 打开index.ets文件,点击预览器中的 ![zh-cn_image_0000001262219043](figures/zh-cn_image_0000001262219043.png) 按钮进行刷新。 效果如下图所示:
![zh-cn_image_0000001260684127](figures/zh-cn_image_0000001260684127.png)
......
......@@ -54,48 +54,48 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
第一个页面内有一个容器、文本和一个按钮,通过Div、Text和Button组件来实现。
1. **删除画布原有模板组件。**<a name= delete_origin_content></a>
1. 删除画布原有模板组件。<a name= delete_origin_content></a>
打开index.visual文件,选中画布中的组件,单击鼠标右键,选择Delete删除画布原有模板组件。操作如下所示:
![zh-cn_image_0000001216600980](figures/zh-cn_image_0000001216600980.gif)
2. **添加容器,设置Div容器的样式和属性。**<a name = add_container></a>
2. 添加容器,设置Div容器的样式和属性。<a name = add_container></a>
选中UI Control中的Div组件,将其拖至画布。点击右侧属性样式栏中的样式图标![zh-cn_image_0000001260226691](figures/zh-cn_image_0000001260226691.png)(General),设置Div组件的高度Height为100%,使其占满屏幕;点击右侧属性样式栏中的样式图标![zh-cn_image_0000001215226858](figures/zh-cn_image_0000001215226858.png)(Flex),设置Div组件的FlexDirection样式为column,使Div的主轴垂直;设置Div组件的JustifyContent样式为center,使得其子组件在主轴上居中显示;设置Div组件的AlignItems样式为center,使得其子组件在交叉轴上居中显示。操作如下所示:
![zh-cn_image_0000001216448880](figures/zh-cn_image_0000001216448880.gif)
3. **添加文本。**
3. 添加文本。
选中UI Control中的Text组件,将其拖至Div组件的中央区域。点击右侧属性样式栏中的属性图标![zh-cn_image_0000001215066868](figures/zh-cn_image_0000001215066868.png)(Properties),设置Text组件的Content属性为“Hello World”;点击右侧属性样式栏中的样式图标![zh-cn_image_0000001215386842](figures/zh-cn_image_0000001215386842.png)(Feature),设置组件的FontSize样式为60px,使得其文字放大;设置组件的TextAlign样式为center,使得组件文字居中显示。再选中画布上的Text组件,拖动放大。操作如下所示:
![zh-cn_image_0000001216446670](figures/zh-cn_image_0000001216446670.gif)
4. **添加按钮。**
4. 添加按钮。
选中UI Control中的Button组件,将其拖至Text组件下面。点击右侧属性样式栏中的属性图标![zh-cn_image_0000001260106745](figures/zh-cn_image_0000001260106745.png)(Properties),设置Button组件的Value属性为“Next”,点击右侧属性样式栏中的样式图标![zh-cn_image_0000001259866741](figures/zh-cn_image_0000001259866741.png)(Feature),设置组件的FontSize样式为40px,使得其文字放大;再选中画布上的Button组件,拖动放大。操作如下所示:
![zh-cn_image_0000001260928361](figures/zh-cn_image_0000001260928361.gif)
5. **在编辑窗口右上角的侧边工具栏,点击Previewer,打开预览器。** 第一个页面效果如下图所示:
5. 在编辑窗口右上角的侧边工具栏,点击Previewer,打开预览器。第一个页面效果如下图所示:
![zh-cn_image_0000001216288558](figures/zh-cn_image_0000001216288558.png)
## 构建第二个页面
1. **创建第二个页面。**
1. 创建第二个页面。
在“**Project**”窗口,打开“**entry &gt; src &gt; main &gt; js &gt; MainAbility**”,右键点击“**pages**”文件夹,选择“**New &gt; Visual**”,命名为“**second**”,单击“**Finish**”,即完成第二个页面的创建。可以看到文件目录结构如下:
![zh-cn_image_0000001223882030](figures/zh-cn_image_0000001223882030.png)
2. **[删除画布原有模板组件。](#delete_origin_content)**
2. [删除画布原有模板组件。](#delete_origin_content)
3. **[添加容器,设置Div容器的样式和属性。](#add_container)**
3. [添加容器,设置Div容器的样式和属性。](#add_container)
4. **添加文本。**
4. 添加文本。
选中Text组件,拖至Div组件的中央区域。点击右侧属性样式栏中的属性图标![zh-cn_image_0000001260227453](figures/zh-cn_image_0000001260227453.png)(Properties),设置Text组件的Content属性为“Hi there”;点击右侧属性样式栏中的样式图标![zh-cn_image_0000001260107497](figures/zh-cn_image_0000001260107497.png)(Feature),设置组件的FontSize样式为60px;设置组件的TextAlign样式为center。再选中画布上的Text组件,拖动放大。操作如下所示:
![zh-cn_image_0000001216614132](figures/zh-cn_image_0000001216614132.gif)
5. **添加按钮。**
5. 添加按钮。
选中UI Control中的Button组件,将其拖至Text组件下面。点击右侧属性样式栏中的属性图标![zh-cn_image_0000001215227618](figures/zh-cn_image_0000001215227618.png)(Properties),设置Button组件的Value属性为“Back”,点击右侧属性样式栏中的样式图标![zh-cn_image_0000001259987441](figures/zh-cn_image_0000001259987441.png)(Feature),设置组件的FontSize样式为40px,使得其文字放大;再选中画布上的Button组件,拖动放大。操作如下所示:
![zh-cn_image_0000001261017331](figures/zh-cn_image_0000001261017331.gif)
......@@ -105,7 +105,7 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
页面间的导航可以通过[页面路由router](../ui/ui-js-building-ui-routes.md)来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。
1. **第一个页面跳转到第二个页面。**
1. 第一个页面跳转到第二个页面。
在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。需同时处理js文件及visual文件。
-**index.js**”示例如下:
......@@ -125,7 +125,7 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
![zh-cn_image_0000001223722586](figures/zh-cn_image_0000001223722586.png)
2. **第二个页面返回到第一个页面。**
2. 第二个页面返回到第一个页面。
在第二个页面中,返回按钮绑定back方法,点击按钮时返回到第一页。
需同时处理js文件及visual文件。
......@@ -145,7 +145,7 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
![zh-cn_image_0000001268082945](figures/zh-cn_image_0000001268082945.png)
3. **打开index.visual或index.js文件,点击预览器中的** ![zh-cn_image_0000001261979271](figures/zh-cn_image_0000001261979271.png) **按钮进行刷新。** 效果如下图所示:
3. 打开index.visual或index.js文件,点击预览器中的 ![zh-cn_image_0000001261979271](figures/zh-cn_image_0000001261979271.png) 按钮进行刷新。效果如下图所示:
![zh-cn_image_0000001261142799](figures/zh-cn_image_0000001261142799.png)
......
......@@ -28,7 +28,7 @@
- **src &gt; main &gt; js &gt; MainAbility &gt; app.js** :承载Ability生命周期。
- **src &gt; main &gt; resources** :用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。
- **src &gt; main &gt; config.json** :模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。
- **src &gt; main &gt; config.json** :模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[应用包结构配置文件的说明](package-structure.md)
- **build-profile.json5** :当前的模块信息 、编译信息配置项,包括 buildOption target配置等。
- **hvigorfile.js** :模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。
......@@ -39,7 +39,7 @@
## 构建第一个页面
1. **使用文本组件。**
1. 使用文本组件。
工程同步完成后,在“**Project**”窗口,点击“**entry &gt; src &gt; main &gt; js &gt; MainAbility &gt; pages&gt; index**”,打开“**index.hml**”文件,设置Text组件内容。“**index.hml**”文件的示例如下:
......@@ -51,7 +51,7 @@
</div>
```
2. **添加按钮,并绑定onclick方法。**
2. 添加按钮,并绑定onclick方法。
在默认页面基础上,我们添加一个button类型的input组件,作为按钮接收用户点击的动作,从而实现跳转到另一个页面。“**index.hml**”文件的示例代码如下:
......@@ -66,7 +66,7 @@
</div>
```
3. **设置页面样式。**
3. 设置页面样式。
在“**Project**”窗口,点击“**entry &gt; src &gt; main &gt; js &gt; MainAbility &gt; pages&gt; index**”,打开“**index.css**”文件,可以对页面中文本、按钮设置宽高、字体大小、间距等样式。“**index.css**”文件的示例如下:
......@@ -100,7 +100,7 @@
}
```
4. **在编辑窗口右上角的侧边工具栏,点击Previewer,打开预览器。** 第一个页面效果如下图所示:
4. 在编辑窗口右上角的侧边工具栏,点击Previewer,打开预览器。第一个页面效果如下图所示:
![zh-cn_image_0000001216084724](figures/zh-cn_image_0000001216084724.png)
......@@ -108,12 +108,12 @@
## 构建第二个页面
1. **创建第二个页面。**
1. 创建第二个页面。
在“**Project**”窗口,打开“**entry &gt; src &gt; main &gt; js &gt; MainAbility**”,右键点击“**pages**”文件夹,选择“**New &gt; Page**”,命名为“**second**”,点击“**Finish**”,即完成第二个页面的创建。可以看到文件目录结构如下:
![zh-cn_image_0000001223877210](figures/zh-cn_image_0000001223877210.png)
2. **添加文本及按钮。**
2. 添加文本及按钮。
参照第一个页面,在第二个页面添加文本、按钮及点击按钮绑定页面返回等。“**second.hml**”文件的示例如下:
......@@ -128,7 +128,7 @@
</div>
```
3. **设置页面样式**。“**second.css**”文件的示例如下:
3. 设置页面样式。“**second.css**”文件的示例如下:
```
.container {
......@@ -165,7 +165,7 @@
页面间的导航可以通过[页面路由router](../ui/ui-js-building-ui-routes.md)来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。
1. **第一个页面跳转到第二个页面。**
1. 第一个页面跳转到第二个页面。
在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。“**index.js**”示例如下:
......@@ -181,7 +181,7 @@
}
```
2. **第二个页面返回到第一个页面。**
2. 第二个页面返回到第一个页面。
在第二个页面中,返回按钮绑定back方法,点击按钮时返回到第一页。“**second.js**”示例如下:
......@@ -195,7 +195,7 @@
}
```
3. **打开index文件夹下的任意一个文件,点击预览器中的** ![zh-cn_image_0000001262339067](figures/zh-cn_image_0000001262339067.png) **按钮进行刷新。** 效果如下图所示:
3. 打开index文件夹下的任意一个文件,点击预览器中的 ![zh-cn_image_0000001262339067](figures/zh-cn_image_0000001262339067.png) 按钮进行刷新。效果如下图所示:
![zh-cn_image_0000001216269940](figures/zh-cn_image_0000001216269940.png)
......
......@@ -143,7 +143,7 @@ Ability生命周期回调,在销毁时回调,执行资源清理等操作。
onForeground(): void;
Ability生命周期回调,当应用处于前台时触发。
Ability生命周期回调,当应用从后台转到前台时触发。
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore
......@@ -162,7 +162,7 @@ Ability生命周期回调,当应用处于前台时触发。
onBackground(): void;
Ability生命周期回调,当应用处于后台时触发。
Ability生命周期回调,当应用从前台转到后台时触发。
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册