未验证 提交 c782733e 编写于 作者: O openharmony_ci 提交者: Gitee

!10907 翻译已完成9990+10024+10025+10028+10054

Merge pull request !10907 from shawn_he/9990-a
...@@ -12,12 +12,10 @@ The following table provides only a brief description of related APIs. For detai ...@@ -12,12 +12,10 @@ The following table provides only a brief description of related APIs. For detai
**Table 1** APIs for application event logging **Table 1** APIs for application event logging
| API | Description | | API | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------------ | ---------------------------------------------------- |
| write(string eventName, EventType type, object keyValues, AsyncCallback\<void> callback): void | Logs application events in asynchronous mode. This API uses an asynchronous callback to return the result. | | write(AppEventInfo info, AsyncCallback\<void> callback): void | Logs application events in asynchronous mode. This API uses an asynchronous callback to return the result.|
| write(string eventName, EventType type, object keyValues): Promise\<void> | Logs application events in asynchronous mode. This API uses a promise to return the result. | | write(AppEventInfo info): Promise\<void> | Logs application events in asynchronous mode. This API uses a promise to return the result. |
| write(AppEventInfo info, AsyncCallback\<void> callback): void | Logs application events by domain in asynchronous mode. This API uses an asynchronous callback to return the result.|
| write(AppEventInfo info): Promise\<void> | Logs application events by domain in asynchronous mode. This API uses a promise to return the result.|
When an asynchronous callback is used, the return value can be processed directly in the callback. When an asynchronous callback is used, the return value can be processed directly in the callback.
...@@ -84,6 +82,7 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -84,6 +82,7 @@ The following uses a one-time event watcher as an example to illustrate the deve
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("1 writeTest").onClick(()=>{ Button("1 writeTest").onClick(()=>{
// Perform event logging based on the input event parameters.
hiAppEvent.write({ hiAppEvent.write({
domain: "test_domain", domain: "test_domain",
name: "test_event", name: "test_event",
...@@ -100,6 +99,7 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -100,6 +99,7 @@ The following uses a one-time event watcher as an example to illustrate the deve
}) })
Button("2 addWatcherTest").onClick(()=>{ Button("2 addWatcherTest").onClick(()=>{
// Add an event watcher based on the input subscription parameters.
hiAppEvent.addWatcher({ hiAppEvent.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [{ domain: "test_domain" }], appEventFilters: [{ domain: "test_domain" }],
...@@ -109,17 +109,23 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -109,17 +109,23 @@ The following uses a one-time event watcher as an example to illustrate the deve
timeOut: 2 timeOut: 2
}, },
onTrigger: function (curRow, curSize, holder) { onTrigger: function (curRow, curSize, holder) {
// If the holder object is null, return an error after recording it in the log.
if (holder == null) { if (holder == null) {
console.error("HiAppEvent holder is null"); console.error("HiAppEvent holder is null");
return; return;
} }
// Set the size threshold to 1,000 bytes for obtaining an event package.
holder.setSize(1000);
let eventPkg = null; let eventPkg = null;
// Obtain the event package based on the configured size threshold. If returned event package is null, all event data has been obtained.
while ((eventPkg = holder.takeNext()) != null) { while ((eventPkg = holder.takeNext()) != null) {
console.info("HiAppEvent eventPkg.packageId=" + eventPkg.packageId); // Parse the obtained event package and display the result on the Log page.
console.info("HiAppEvent eventPkg.row=" + eventPkg.row); console.info('HiAppEvent eventPkg.packageId=' + eventPkg.packageId);
console.info("HiAppEvent eventPkg.size=" + eventPkg.size); console.info('HiAppEvent eventPkg.row=' + eventPkg.row);
console.info('HiAppEvent eventPkg.size=' + eventPkg.size);
// Traverse and parse event string arrays in the obtained event package.
for (const eventInfo of eventPkg.data) { for (const eventInfo of eventPkg.data) {
console.info("HiAppEvent eventPkg.data=" + eventInfo); console.info('HiAppEvent eventPkg.data=' + eventInfo);
} }
} }
} }
...@@ -127,6 +133,7 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -127,6 +133,7 @@ The following uses a one-time event watcher as an example to illustrate the deve
}) })
Button("3 removeWatcherTest").onClick(()=>{ Button("3 removeWatcherTest").onClick(()=>{
// Remove the specified event watcher.
hiAppEvent.removeWatcher({ hiAppEvent.removeWatcher({
name: "watcher1" name: "watcher1"
}) })
......
...@@ -827,7 +827,7 @@ call.reject(1, (error, data) => { ...@@ -827,7 +827,7 @@ call.reject(1, (error, data) => {
## call.reject<sup>7+</sup> ## call.reject<sup>7+</sup>
reject\(callId: number, options: RejectMessageOption, callback: AsyncCallback<void\>\): void reject\(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void\>\): void
Rejects a call based on the specified call ID and options. This API uses an asynchronous callback to return the result. Rejects a call based on the specified call ID and options. This API uses an asynchronous callback to return the result.
......
...@@ -202,8 +202,8 @@ Updates a contact based on the specified contact information and attributes. Thi ...@@ -202,8 +202,8 @@ Updates a contact based on the specified contact information and attributes. Thi
contact.updateContact({ contact.updateContact({
name: {fullName: 'xxx'}, name: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
},{ }, {
attributes:[contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME] attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err) => { }, (err) => {
if (err) { if (err) {
console.log('updateContact callback: err->${JSON.stringify(err)}'); console.log('updateContact callback: err->${JSON.stringify(err)}');
...@@ -432,7 +432,7 @@ Queries my card based on the specified contact attributes. This API uses an asyn ...@@ -432,7 +432,7 @@ Queries my card based on the specified contact attributes. This API uses an asyn
```js ```js
contact.queryMyCard({ contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME'] attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err, data) => { }, (err, data) => {
if (err) { if (err) {
console.log(`queryMyCard callback: err->${JSON.stringify(err)}`); console.log(`queryMyCard callback: err->${JSON.stringify(err)}`);
...@@ -469,7 +469,7 @@ Queries my card based on the specified contact attributes. This API uses a promi ...@@ -469,7 +469,7 @@ Queries my card based on the specified contact attributes. This API uses a promi
```js ```js
let promise = contact.queryMyCard({ let promise = contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME'] attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}); });
promise.then((data) => { promise.then((data) => {
console.log(`queryMyCard success: data->${JSON.stringify(data)}`); console.log(`queryMyCard success: data->${JSON.stringify(data)}`);
...@@ -487,7 +487,7 @@ Selects a contact. This API uses an asynchronous callback to return the result. ...@@ -487,7 +487,7 @@ Selects a contact. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.READ_CONTACTS **Permission required**: ohos.permission.READ_CONTACTS
**System capability**: SystemCapability.Applications.ContactsData **System capability**: SystemCapability.Applications.Contacts
**Parameters** **Parameters**
...@@ -516,7 +516,7 @@ Selects a contact. This API uses a promise to return the result. ...@@ -516,7 +516,7 @@ Selects a contact. This API uses a promise to return the result.
**Permission required**: ohos.permission.READ_CONTACTS **Permission required**: ohos.permission.READ_CONTACTS
**System capability**: SystemCapability.Applications.ContactsData **System capability**: SystemCapability.Applications.Contacts
**Return Value** **Return Value**
......
...@@ -384,6 +384,27 @@ promise.then(data => { ...@@ -384,6 +384,27 @@ promise.then(data => {
}); });
``` ```
## radio.isNrSupported<sup>7+</sup>
isNrSupported\(\): boolean
Checks whether the current device supports 5G \(NR\).
**System capability**: SystemCapability.Telephony.CoreService
**Return value**
| Type | Description |
| ------- | -------------------------------- |
| boolean | - **true**: The current device supports 5G \(NR\).<br>- **false**: The current device does not support 5G \(NR\).|
**Example**
```js
let result = radio.isNrSupported();
console.log("Result: "+ result);
```
## radio.isNrSupported<sup>8+</sup> ## radio.isNrSupported<sup>8+</sup>
......
...@@ -2683,8 +2683,6 @@ getOpKey(slotId: number): Promise<string\> ...@@ -2683,8 +2683,6 @@ getOpKey(slotId: number): Promise<string\>
Obtains the opkey of the SIM card in the specified slot. This API uses a promise to return the result. Obtains the opkey of the SIM card in the specified slot. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
**Parameters** **Parameters**
...@@ -2716,8 +2714,6 @@ getOpName(slotId: number, callback: AsyncCallback<string\>): void ...@@ -2716,8 +2714,6 @@ getOpName(slotId: number, callback: AsyncCallback<string\>): void
Obtains the OpName of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. Obtains the OpName of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
**Parameters** **Parameters**
...@@ -2742,8 +2738,6 @@ getOpName(slotId: number): Promise<string\> ...@@ -2742,8 +2738,6 @@ getOpName(slotId: number): Promise<string\>
Obtains the OpName of the SIM card in the specified slot. This API uses a promise to return the result. Obtains the OpName of the SIM card in the specified slot. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
**Parameters** **Parameters**
......
...@@ -63,6 +63,29 @@ promise.then((data) => { ...@@ -63,6 +63,29 @@ promise.then((data) => {
}); });
``` ```
## data.getDefaultCellularDataSlotIdSync
getDefaultCellularDataSlotIdSync(): number
Obtains the default SIM card used for mobile data synchronously.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData
**Return value**
| Type | Description |
| ------ | -------------------------------------------------- |
| number | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2|
**Example**
```js
console.log("Result: "+ data.getDefaultCellularDataSlotIdSync())
```
## data.setDefaultCellularDataSlotId ## data.setDefaultCellularDataSlotId
setDefaultCellularDataSlotId(slotId: number,callback: AsyncCallback\<void\>): void setDefaultCellularDataSlotId(slotId: number,callback: AsyncCallback\<void\>): void
......
...@@ -43,13 +43,13 @@ Obtains an **OnlineUpdater** object. ...@@ -43,13 +43,13 @@ Obtains an **OnlineUpdater** object.
```ts ```ts
try { try {
var upgradeInfo = { const upgradeInfo = {
upgradeApp: "com.ohos.ota.updateclient", upgradeApp: "com.ohos.ota.updateclient",
businessType: { businessType: {
vendor: update.BusinessVendor.PUBLIC, vendor: update.BusinessVendor.PUBLIC,
subType: update.BusinessSubType.FIRMWARE subType: update.BusinessSubType.FIRMWARE
} }
} };
let updater = update.getOnlineUpdater(upgradeInfo); let updater = update.getOnlineUpdater(upgradeInfo);
} catch(error) { } catch(error) {
console.error(`Fail to get updater error: ${error}`); console.error(`Fail to get updater error: ${error}`);
...@@ -233,15 +233,15 @@ Obtains the description file of the new version. This API uses an asynchronous c ...@@ -233,15 +233,15 @@ Obtains the description file of the new version. This API uses an asynchronous c
```ts ```ts
// Version digest information // Version digest information
var versionDigestInfo = { const versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result versionDigest: "versionDigest" // Version digest information in the check result
} };
// Options of the description file // Options of the description file
var descriptionOptions = { const descriptionOptions = {
format: update.DescriptionFormat.STANDARD, // Standard format format: update.DescriptionFormat.STANDARD, // Standard format
language: "zh-cn" // Chinese language: "zh-cn" // Chinese
} };
updater.getNewVersionDescription(versionDigestInfo, descriptionOptions, (err, info) => { updater.getNewVersionDescription(versionDigestInfo, descriptionOptions, (err, info) => {
console.log(`getNewVersionDescription info ${JSON.stringify(info)}`); console.log(`getNewVersionDescription info ${JSON.stringify(info)}`);
...@@ -276,15 +276,15 @@ Obtains the description file of the new version. This API uses a promise to retu ...@@ -276,15 +276,15 @@ Obtains the description file of the new version. This API uses a promise to retu
```ts ```ts
// Version digest information // Version digest information
var versionDigestInfo = { const versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result versionDigest: "versionDigest" // Version digest information in the check result
} };
// Options of the description file // Options of the description file
var descriptionOptions = { const descriptionOptions = {
format: update.DescriptionFormat.STANDARD, // Standard format format: update.DescriptionFormat.STANDARD, // Standard format
language: "zh-cn" // Chinese language: "zh-cn" // Chinese
} };
updater.getNewVersionDescription(versionDigestInfo, descriptionOptions).then(info => { updater.getNewVersionDescription(versionDigestInfo, descriptionOptions).then(info => {
console.log(`getNewVersionDescription promise info ${JSON.stringify(info)}`); console.log(`getNewVersionDescription promise info ${JSON.stringify(info)}`);
...@@ -368,10 +368,10 @@ Obtains the description file of the current version. This API uses an asynchrono ...@@ -368,10 +368,10 @@ Obtains the description file of the current version. This API uses an asynchrono
```ts ```ts
// Options of the description file // Options of the description file
var descriptionOptions = { const descriptionOptions = {
format: update.DescriptionFormat.STANDARD, // Standard format format: update.DescriptionFormat.STANDARD, // Standard format
language: "zh-cn" // Chinese language: "zh-cn" // Chinese
} };
updater.getCurrentVersionDescription(descriptionOptions, (err, info) => { updater.getCurrentVersionDescription(descriptionOptions, (err, info) => {
console.log(`getCurrentVersionDescription info ${JSON.stringify(info)}`); console.log(`getCurrentVersionDescription info ${JSON.stringify(info)}`);
...@@ -405,10 +405,10 @@ Obtains the description file of the current version. This API uses a promise to ...@@ -405,10 +405,10 @@ Obtains the description file of the current version. This API uses a promise to
```ts ```ts
// Options of the description file // Options of the description file
var descriptionOptions = { const descriptionOptions = {
format: update.DescriptionFormat.STANDARD, // Standard format format: update.DescriptionFormat.STANDARD, // Standard format
language: "zh-cn" // Chinese language: "zh-cn" // Chinese
} };
updater.getCurrentVersionDescription(descriptionOptions).then(info => { updater.getCurrentVersionDescription(descriptionOptions).then(info => {
console.log(`getCurrentVersionDescription promise info ${JSON.stringify(info)}`); console.log(`getCurrentVersionDescription promise info ${JSON.stringify(info)}`);
...@@ -489,15 +489,15 @@ Downloads the new version. This API uses an asynchronous callback to return the ...@@ -489,15 +489,15 @@ Downloads the new version. This API uses an asynchronous callback to return the
```ts ```ts
// Version digest information // Version digest information
var versionDigestInfo = { const versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result versionDigest: "versionDigest" // Version digest information in the check result
} };
// Download options // Download options
var downloadOptions = { const downloadOptions = {
allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
order: update.Order.DOWNLOAD // Download order: update.Order.DOWNLOAD // Download
} };
updater.download(versionDigestInfo, downloadOptions, (err) => { updater.download(versionDigestInfo, downloadOptions, (err) => {
console.log(`download error ${JSON.stringify(err)}`); console.log(`download error ${JSON.stringify(err)}`);
}); });
...@@ -530,15 +530,15 @@ Downloads the new version. This API uses a promise to return the result. ...@@ -530,15 +530,15 @@ Downloads the new version. This API uses a promise to return the result.
```ts ```ts
// Version digest information // Version digest information
var versionDigestInfo = { const versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result versionDigest: "versionDigest" // Version digest information in the check result
} };
// Download options // Download options
var downloadOptions = { const downloadOptions = {
allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
order: update.Order.DOWNLOAD // Download order: update.Order.DOWNLOAD // Download
} };
updater.download(versionDigestInfo, downloadOptions).then(() => { updater.download(versionDigestInfo, downloadOptions).then(() => {
console.log(`download start`); console.log(`download start`);
}).catch(err => { }).catch(err => {
...@@ -568,14 +568,14 @@ Resumes download of the new version. This API uses an asynchronous callback to r ...@@ -568,14 +568,14 @@ Resumes download of the new version. This API uses an asynchronous callback to r
```ts ```ts
// Version digest information // Version digest information
var versionDigestInfo = { const versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result versionDigest: "versionDigest" // Version digest information in the check result
} };
// Options for resuming download // Options for resuming download
var resumeDownloadOptions = { const resumeDownloadOptions = {
allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
} };
updater.resumeDownload(versionDigestInfo, resumeDownloadOptions, (err) => { updater.resumeDownload(versionDigestInfo, resumeDownloadOptions, (err) => {
console.log(`resumeDownload error ${JSON.stringify(err)}`); console.log(`resumeDownload error ${JSON.stringify(err)}`);
}); });
...@@ -608,14 +608,14 @@ Resumes download of the new version. This API uses a promise to return the resul ...@@ -608,14 +608,14 @@ Resumes download of the new version. This API uses a promise to return the resul
```ts ```ts
// Version digest information // Version digest information
var versionDigestInfo = { const versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result versionDigest: "versionDigest" // Version digest information in the check result
} };
// Options for resuming download // Options for resuming download
var resumeDownloadOptions = { const resumeDownloadOptions = {
allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network
} };
updater.resumeDownload(versionDigestInfo, resumeDownloadOptions).then(value => { updater.resumeDownload(versionDigestInfo, resumeDownloadOptions).then(value => {
console.log(`resumeDownload start`); console.log(`resumeDownload start`);
}).catch(err => { }).catch(err => {
...@@ -645,14 +645,14 @@ Pauses download of the new version. This API uses an asynchronous callback to re ...@@ -645,14 +645,14 @@ Pauses download of the new version. This API uses an asynchronous callback to re
```ts ```ts
// Version digest information // Version digest information
var versionDigestInfo = { const versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result versionDigest: "versionDigest" // Version digest information in the check result
} };
// Options for pausing download // Options for pausing download
var pauseDownloadOptions = { const pauseDownloadOptions = {
isAllowAutoResume: true // Whether to allow automatic resuming of download isAllowAutoResume: true // Whether to allow automatic resuming of download
} };
updater.pauseDownload(versionDigestInfo, pauseDownloadOptions, (err) => { updater.pauseDownload(versionDigestInfo, pauseDownloadOptions, (err) => {
console.log(`pauseDownload error ${JSON.stringify(err)}`); console.log(`pauseDownload error ${JSON.stringify(err)}`);
}); });
...@@ -685,14 +685,14 @@ Resumes download of the new version. This API uses a promise to return the resul ...@@ -685,14 +685,14 @@ Resumes download of the new version. This API uses a promise to return the resul
```ts ```ts
// Version digest information // Version digest information
var versionDigestInfo = { const versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result versionDigest: "versionDigest" // Version digest information in the check result
} };
// Options for pausing download // Options for pausing download
var pauseDownloadOptions = { const pauseDownloadOptions = {
isAllowAutoResume: true // Whether to allow automatic resuming of download isAllowAutoResume: true // Whether to allow automatic resuming of download
} };
updater.pauseDownload(versionDigestInfo, pauseDownloadOptions).then(value => { updater.pauseDownload(versionDigestInfo, pauseDownloadOptions).then(value => {
console.log(`pauseDownload`); console.log(`pauseDownload`);
}).catch(err => { }).catch(err => {
...@@ -722,14 +722,14 @@ Updates the version. This API uses an asynchronous callback to return the result ...@@ -722,14 +722,14 @@ Updates the version. This API uses an asynchronous callback to return the result
```ts ```ts
// Version digest information // Version digest information
var versionDigestInfo = { const versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result versionDigest: "versionDigest" // Version digest information in the check result
} };
// Installation options // Installation options
var upgradeOptions = { const upgradeOptions = {
order: update.Order.INSTALL // Installation command order: update.Order.INSTALL // Installation command
} };
updater.upgrade(versionDigestInfo, upgradeOptions, (err) => { updater.upgrade(versionDigestInfo, upgradeOptions, (err) => {
console.log(`upgrade error ${JSON.stringify(err)}`); console.log(`upgrade error ${JSON.stringify(err)}`);
}); });
...@@ -762,14 +762,14 @@ Updates the version. This API uses a promise to return the result. ...@@ -762,14 +762,14 @@ Updates the version. This API uses a promise to return the result.
```ts ```ts
// Version digest information // Version digest information
var versionDigestInfo = { const versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result versionDigest: "versionDigest" // Version digest information in the check result
} };
// Installation options // Installation options
var upgradeOptions = { const upgradeOptions = {
order: update.Order.INSTALL // Installation command order: update.Order.INSTALL // Installation command
} };
updater.upgrade(versionDigestInfo, upgradeOptions).then(() => { updater.upgrade(versionDigestInfo, upgradeOptions).then(() => {
console.log(`upgrade start`); console.log(`upgrade start`);
}).catch(err => { }).catch(err => {
...@@ -799,14 +799,14 @@ Clears errors. This API uses an asynchronous callback to return the result. ...@@ -799,14 +799,14 @@ Clears errors. This API uses an asynchronous callback to return the result.
```ts ```ts
// Version digest information // Version digest information
var versionDigestInfo = { const versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result versionDigest: "versionDigest" // Version digest information in the check result
} };
// Options for clearing errors // Options for clearing errors
var clearOptions = { const clearOptions = {
status: update.UpgradeStatus.UPGRADE_FAIL, status: update.UpgradeStatus.UPGRADE_FAIL,
} };
updater.clearError(versionDigestInfo, clearOptions, (err) => { updater.clearError(versionDigestInfo, clearOptions, (err) => {
console.log(`clearError error ${JSON.stringify(err)}`); console.log(`clearError error ${JSON.stringify(err)}`);
}); });
...@@ -839,14 +839,14 @@ Clears errors. This API uses a promise to return the result. ...@@ -839,14 +839,14 @@ Clears errors. This API uses a promise to return the result.
```ts ```ts
// Version digest information // Version digest information
var versionDigestInfo = { const versionDigestInfo = {
versionDigest: "versionDigest" // Version digest information in the check result versionDigest: "versionDigest" // Version digest information in the check result
} };
// Options for clearing errors // Options for clearing errors
var clearOptions = { lconstet clearOptions = {
status: update.UpgradeStatus.UPGRADE_FAIL, status: update.UpgradeStatus.UPGRADE_FAIL,
} };
updater.clearError(versionDigestInfo, clearOptions).then(() => { updater.clearError(versionDigestInfo, clearOptions).then(() => {
console.log(`clearError success`); console.log(`clearError success`);
}).catch(err => { }).catch(err => {
...@@ -926,7 +926,7 @@ Sets the update policy. This API uses an asynchronous callback to return the res ...@@ -926,7 +926,7 @@ Sets the update policy. This API uses an asynchronous callback to return the res
**Example** **Example**
```ts ```ts
let policy = { const policy = {
downloadStrategy: false, downloadStrategy: false,
autoUpgradeStrategy: false, autoUpgradeStrategy: false,
autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes
...@@ -961,7 +961,7 @@ Sets the update policy. This API uses a promise to return the result. ...@@ -961,7 +961,7 @@ Sets the update policy. This API uses a promise to return the result.
**Example** **Example**
```ts ```ts
let policy = { const policy = {
downloadStrategy: false, downloadStrategy: false,
autoUpgradeStrategy: false, autoUpgradeStrategy: false,
autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes
...@@ -1041,10 +1041,10 @@ Enables listening for update events. This API uses an asynchronous callback to r ...@@ -1041,10 +1041,10 @@ Enables listening for update events. This API uses an asynchronous callback to r
**Example** **Example**
```ts ```ts
var eventClassifyInfo = { const eventClassifyInfo = {
eventClassify: update.EventClassify.TASK, // Listening for update events eventClassify: update.EventClassify.TASK, // Listening for update events
extraInfo: "" extraInfo: ""
} };
updater.on(eventClassifyInfo, (eventInfo) => { updater.on(eventClassifyInfo, (eventInfo) => {
console.log("updater on " + JSON.stringify(eventInfo)); console.log("updater on " + JSON.stringify(eventInfo));
...@@ -1068,10 +1068,10 @@ Disables listening for update events. This API uses an asynchronous callback to ...@@ -1068,10 +1068,10 @@ Disables listening for update events. This API uses an asynchronous callback to
**Example** **Example**
```ts ```ts
var eventClassifyInfo = { const eventClassifyInfo = {
eventClassify: update.EventClassify.TASK, // Listening for update events eventClassify: update.EventClassify.TASK, // Listening for update events
extraInfo: "" extraInfo: ""
} };
updater.off(eventClassifyInfo, (eventInfo) => { updater.off(eventClassifyInfo, (eventInfo) => {
console.log("updater off " + JSON.stringify(eventInfo)); console.log("updater off " + JSON.stringify(eventInfo));
...@@ -1153,10 +1153,10 @@ Verifies the update package. This API uses an asynchronous callback to return th ...@@ -1153,10 +1153,10 @@ Verifies the update package. This API uses an asynchronous callback to return th
**Example** **Example**
```ts ```ts
var upgradeFile = { const upgradeFile = {
fileType: update.ComponentType.OTA, // OTA package fileType: update.ComponentType.OTA, // OTA package
filePath: "path" // Path of the local update package filePath: "path" // Path of the local update package
} };
localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath", (err) => { localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath", (err) => {
console.log(`factoryReset error ${JSON.stringify(err)}`); console.log(`factoryReset error ${JSON.stringify(err)}`);
...@@ -1189,10 +1189,10 @@ Verifies the update package. This API uses a promise to return the result. ...@@ -1189,10 +1189,10 @@ Verifies the update package. This API uses a promise to return the result.
**Example** **Example**
```ts ```ts
var upgradeFile = { const upgradeFile = {
fileType: update.ComponentType.OTA, // OTA package fileType: update.ComponentType.OTA, // OTA package
filePath: "path" // Path of the local update package filePath: "path" // Path of the local update package
} };
localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath").then(() => { localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath").then(() => {
console.log(`verifyUpgradePackage success`); console.log(`verifyUpgradePackage success`);
}).catch(err => { }).catch(err => {
...@@ -1219,10 +1219,10 @@ Installs the update package. This API uses an asynchronous callback to return th ...@@ -1219,10 +1219,10 @@ Installs the update package. This API uses an asynchronous callback to return th
**Example** **Example**
```ts ```ts
var upgradeFiles = [{ const upgradeFiles = [{
fileType: update.ComponentType.OTA, // OTA package fileType: update.ComponentType.OTA, // OTA package
filePath: "path" // Path of the local update package filePath: "path" // Path of the local update package
}] }];
localUpdater.applyNewVersion(upgradeFiles, (err) => { localUpdater.applyNewVersion(upgradeFiles, (err) => {
console.log(`applyNewVersion error ${JSON.stringify(err)}`); console.log(`applyNewVersion error ${JSON.stringify(err)}`);
...@@ -1248,10 +1248,10 @@ Installs the update package. This API uses a promise to return the result. ...@@ -1248,10 +1248,10 @@ Installs the update package. This API uses a promise to return the result.
**Example** **Example**
```ts ```ts
var upgradeFiles = [{ localUpdater upgradeFiles = [{
fileType: update.ComponentType.OTA, // OTA package fileType: update.ComponentType.OTA, // OTA package
filePath: "path" // Path of the local update package filePath: "path" // Path of the local update package
}] }];
localUpdater.applyNewVersion(upgradeFiles).then(() => { localUpdater.applyNewVersion(upgradeFiles).then(() => {
console.log(`applyNewVersion success`); console.log(`applyNewVersion success`);
}).catch(err => { }).catch(err => {
...@@ -1276,10 +1276,10 @@ Enables listening for update events. This API uses an asynchronous callback to r ...@@ -1276,10 +1276,10 @@ Enables listening for update events. This API uses an asynchronous callback to r
**Example** **Example**
```ts ```ts
var eventClassifyInfo = { const eventClassifyInfo = {
eventClassify: update.EventClassify.TASK, // Listening for update events eventClassify: update.EventClassify.TASK, // Listening for update events
extraInfo: "" extraInfo: ""
} };
function onTaskUpdate(eventInfo) { function onTaskUpdate(eventInfo) {
console.log(`on eventInfo id `, eventInfo.eventId); console.log(`on eventInfo id `, eventInfo.eventId);
...@@ -1305,10 +1305,10 @@ Disables listening for update events. This API uses an asynchronous callback to ...@@ -1305,10 +1305,10 @@ Disables listening for update events. This API uses an asynchronous callback to
**Example** **Example**
```ts ```ts
var eventClassifyInfo = { const eventClassifyInfo = {
eventClassify: update.EventClassify.TASK, // Listening for update events eventClassify: update.EventClassify.TASK, // Listening for update events
extraInfo: "" extraInfo: ""
} };
function onTaskUpdate(eventInfo) { function onTaskUpdate(eventInfo) {
console.log(`on eventInfo id `, eventInfo.eventId); console.log(`on eventInfo id `, eventInfo.eventId);
......
...@@ -7,7 +7,7 @@ OpenHarmony provides the following two types of Docker environments for you to q ...@@ -7,7 +7,7 @@ OpenHarmony provides the following two types of Docker environments for you to q
- Standalone Docker environment: applicable when using Ubuntu or Windows to build a distribution - Standalone Docker environment: applicable when using Ubuntu or Windows to build a distribution
- HPM-based Docker environment: applicable when using the HarmonyOS Package Manager \(HPM\) to build a distribution - HPM-based Docker environment: applicable when using the HarmonyOS Package Manager \(HPM\) to build a distribution
**Table 1** Docker image **Table 1** Docker image
<a name="table11986917191214"></a> <a name="table11986917191214"></a>
<table><thead align="left"><tr id="row149861417121215"><th class="cellrowborder" valign="top" width="15.831583158315832%" id="mcps1.2.6.1.1"><p id="p798611714124"><a name="p798611714124"></a><a name="p798611714124"></a>Docker Environment</p> <table><thead align="left"><tr id="row149861417121215"><th class="cellrowborder" valign="top" width="15.831583158315832%" id="mcps1.2.6.1.1"><p id="p798611714124"><a name="p798611714124"></a><a name="p798611714124"></a>Docker Environment</p>
...@@ -67,11 +67,12 @@ OpenHarmony provides the following two types of Docker environments for you to q ...@@ -67,11 +67,12 @@ OpenHarmony provides the following two types of Docker environments for you to q
Before using the Docker environment, perform the following operations: Before using the Docker environment, perform the following operations:
1. Install Docker. For details, see [Install Docker Engine](https://docs.docker.com/engine/install/). 1. Install Docker. For details, see [Install Docker Engine](https://docs.docker.com/engine/install/).
2. Obtain the OpenHarmony source code. For details, see [Source Code Acquisition](sourcecode-acquire.md). 2. Obtain the OpenHarmony source code. For details, see [Source Code Acquisition](sourcecode-acquire.md).
>![](../public_sys-resources/icon-note.gif) **NOTE**<br> > **NOTE**
>You do not need to obtain the source code for the HPM-based Docker environment. >
> You do not need to obtain the source code for the HPM-based Docker environment.
## Standalone Docker Environment<a name="section2858536103611"></a> ## Standalone Docker Environment<a name="section2858536103611"></a>
...@@ -94,7 +95,7 @@ The Docker image of OpenHarmony is hosted on HUAWEI CLOUD SWR. Using the Docker ...@@ -94,7 +95,7 @@ The Docker image of OpenHarmony is hosted on HUAWEI CLOUD SWR. Using the Docker
docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0
``` ```
Run the following command in Windows \(assuming that the source code directory is **D:\\OpenHarmony**\): Run the following command in Windows \(assuming that the source code directory is **D:\\OpenHarmony**\):
``` ```
docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0
...@@ -111,17 +112,17 @@ Set the build path to the current path. ...@@ -111,17 +112,17 @@ Set the build path to the current path.
hb set hb set
``` ```
**Figure 1** Setting page<a name="fig7947145854013"></a> **Figure 1** Setting page<a name="fig7947145854013"></a>
![](figure/setting-page.png "setting-page") ![](figure/setting-page.png "setting-page")
>![](../public_sys-resources/icon-note.gif) **NOTE**<br> > **NOTE**<br>
>The mapping between the development board and the building GUI: > The mapping between the development board and the building GUI:
> >
>- Hi3861: wifiiot\_hispark\_pegasus@hisilicon > - Hi3861: wifiiot\_hispark\_pegasus@hisilicon
>- Hi3516: ipcamera\_hispark\_taurus@hisilicon > - Hi3516: ipcamera\_hispark\_taurus@hisilicon
>- Hi3518: ipcamera\_hispark\_aries@hisilicon > - Hi3518: ipcamera\_hispark\_aries@hisilicon
1. Select **ipcamera\_hispark\_taurus@hisilicon** and press **Enter**. 1. Select **ipcamera\_hispark\_taurus@hisilicon** and press **Enter**.
2. Start building. 2. Start building.
``` ```
...@@ -130,7 +131,7 @@ hb set ...@@ -130,7 +131,7 @@ hb set
3. View the build result. 3. View the build result.
The files will be generated in the **out/hispark\_taurus/ipcamera\_hispark\_taurus** directory. The files will be generated in the **out/hispark\_taurus/ipcamera\_hispark\_taurus** directory.
### Setting Up the Docker Environment for Standard-System Devices \(reference memory ≥ 128 MB\)<a name="section13585262391"></a> ### Setting Up the Docker Environment for Standard-System Devices \(reference memory ≥ 128 MB\)<a name="section13585262391"></a>
...@@ -156,17 +157,17 @@ Run the following script to start building for standard-system devices \(referen ...@@ -156,17 +157,17 @@ Run the following script to start building for standard-system devices \(referen
./build.sh --product-name {product_name} --ccache ./build.sh --product-name {product_name} --ccache
``` ```
**product\_name** indicates the platform supported by the current distribution, for example, hispark_taurus_standard and rk3568. **product\_name** indicates the platform supported by the current distribution, for example, hispark_taurus_standard and rk3568.
Files generated during building are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory. Files generated during building are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory.
>![](../public_sys-resources/icon-note.gif) **NOTE**<br> >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>You can exit Docker by simply running the **exit** command. >You can exit Docker by simply running the **exit** command.
## HPM-based Docker Environment<a name="section485713518337"></a> ## HPM-based Docker Environment<a name="section485713518337"></a>
**docker\_dist** is a template component in the [HPM](https://hpm.harmonyos.com/#/en/home) system. It helps to quickly initialize an HPM project and use the Docker image to quickly build a distribution of OpenHarmony, greatly simplifying environment configurations needed for building. After configuring the Ubuntu and hpm-cli development environments, perform the following steps to access the Docker environment: **docker\_dist** is a template component in the [HPM](https://hpm.harmonyos.com/#/en/home) system. It helps to quickly initialize an HPM project and use the Docker image to quickly build a distribution of OpenHarmony, greatly simplifying environment configurations needed for building. After configuring the Ubuntu and hpm-cli development environments, perform the following steps to access the Docker environment:
### Setting Up the Docker Environment<a name="section3295842510"></a> ### Setting Up the Docker Environment<a name="section3295842510"></a>
...@@ -176,20 +177,20 @@ Files generated during building are stored in the **out/{device_name}/** direc ...@@ -176,20 +177,20 @@ Files generated during building are stored in the **out/{device_name}/** direc
hpm init -t @ohos/docker_dist hpm init -t @ohos/docker_dist
``` ```
2. Modify the **publishAs** field. 2. Modify the **publishAs** field.
The obtained bundle is of the template type. Open the **bundle.json** file in the current directory and change the value of **publishAs** from **template** to **distribution** as needed. The obtained bundle is of the template type. Open the **bundle.json** file in the current directory and change the value of **publishAs** from **template** to **distribution** as needed.
### Obtaining and Building Source Code<a name="section69141039143518"></a> ### Obtaining and Building Source Code<a name="section69141039143518"></a>
Start building. Docker can be automatically installed only in Ubuntu. If you are using any other operating system, manually install Docker before pulling the image. Start building. Docker can be automatically installed only in Ubuntu. If you are using any other operating system, manually install Docker before pulling the image.
- **Automatically Installing Docker \(Ubuntu\)** - **Automatically Installing Docker \(Ubuntu\)**
Running the following command will automatically install Docker, pull the Docker image, and start the pulling and building of the corresponding solution in the container. Running the following command will automatically install Docker, pull the Docker image, and start the pulling and building of the corresponding solution in the container.
**Method 1:** **Method 1:**
Add a parameter to specify the solution. For example: Add a parameter to specify the solution. For example:
...@@ -197,9 +198,9 @@ Start building. Docker can be automatically installed only in Ubuntu. If you are ...@@ -197,9 +198,9 @@ Start building. Docker can be automatically installed only in Ubuntu. If you are
hpm run docker solution={product} hpm run docker solution={product}
``` ```
**\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**. **\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**.
**Method 2:** **Method 2:**
Set an environment variable to specify the solution, and then run the build command. Set an environment variable to specify the solution, and then run the build command.
...@@ -209,7 +210,7 @@ Start building. Docker can be automatically installed only in Ubuntu. If you are ...@@ -209,7 +210,7 @@ Start building. Docker can be automatically installed only in Ubuntu. If you are
export solution={product} export solution={product}
``` ```
**\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**. **\{product\}** indicates the solution, for example, **@ohos/hispark\_taurus**, **@ohos/hispark\_aries**, and **@ohos/hispark\_pegasus**.
2. Obtain and build the source code. 2. Obtain and build the source code.
...@@ -217,7 +218,7 @@ Start building. Docker can be automatically installed only in Ubuntu. If you are ...@@ -217,7 +218,7 @@ Start building. Docker can be automatically installed only in Ubuntu. If you are
hpm run docker hpm run docker
``` ```
This example uses the **@ohos/hispark\_taurus** solution for illustration. If the execution is successful, the output is as follows: This example uses the **@ohos/hispark\_taurus** solution for illustration. If the execution is successful, the output is as follows:
``` ```
... ...
...@@ -226,7 +227,7 @@ Start building. Docker can be automatically installed only in Ubuntu. If you are ...@@ -226,7 +227,7 @@ Start building. Docker can be automatically installed only in Ubuntu. If you are
``` ```
- **Manually Installing Docker \(Non-Ubuntu\)** - **Manually Installing Docker \(Non-Ubuntu\)**
Perform the following operations to install Docker: Perform the following operations to install Docker:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册