提交 e91b7d1a 编写于 作者: A Austin 提交者: Gitee

Merge branch 'OpenHarmony-3.1-Release' of gitee.com:openharmony/docs into OpenHarmony-3.1-Release

......@@ -231,7 +231,7 @@ You should override **onDestroy** to delete widget data.
}
```
For details about the persistence method, see [Lightweight Data Store Development](../database/database-preference-guidelines.md).
For details about the persistence method, see [Lightweight Data Store Development](../database/database-storage-guidelines.md).
Note that the **Want** passed by the widget host to the widget provider contains a temporary flag, indicating whether the requested widget is a temporary one.
......
# MissionSnapshot
> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides snapshot of a mission.
Provides the snapshot of a mission.
## Modules to Import
......
......@@ -69,7 +69,7 @@ Checks whether this application is undergoing a stability test. This API uses a
isRamConstrainedDevice(): Promise\<boolean>;
Checks whether this application is running in a RAM constrained device. This API uses a promise to return the result.
Checks whether this application is running on a RAM constrained device. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -77,7 +77,7 @@ Checks whether this application is running in a RAM constrained device. This API
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the application is running in a RAM constrained device. If the application is running in a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| Promise&lt;boolean&gt; | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
......@@ -93,7 +93,7 @@ Checks whether this application is running in a RAM constrained device. This API
isRamConstrainedDevice(callback: AsyncCallback\<boolean>): void;
Checks whether this application is running in a RAM constrained device. This API uses an asynchronous callback to return the result.
Checks whether this application is running on a RAM constrained device. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -101,7 +101,7 @@ Checks whether this application is running in a RAM constrained device. This API
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the application is running in a RAM constrained device. If the application is running in a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
......@@ -214,4 +214,4 @@ Obtains information about the running processes. This API uses an asynchronous c
| pid<sup>8+</sup> | Read only | number | No | Process ID. |
| uid<sup>8+</sup> | Read only | number | No | User ID.|
| processName<sup>8+</sup> | Read only | string | No | Process name.|
| bundleNames<sup>8+</sup> | Read only | Array\<string> | No | **bundleName** array in the running process.|
| bundleNames<sup>8+</sup> | Read only | Array\<string> | No | **bundleName** array in the running processes.|
......@@ -8,7 +8,7 @@ The Battery Info module provides APIs for querying the charger type, battery hea
## Modules to Import<a name="section199443271307"></a>
```
```js
import batteryInfo from '@ohos.batteryInfo';
```
......@@ -126,7 +126,7 @@ Describes battery information.
- Example
```
```js
import batteryInfo from '@ohos.batteryInfo';
var batterySoc = batteryInfo.batterySOC;
```
......
......@@ -8,7 +8,7 @@
## Modules to Import
```
```js
import bluetooth from '@ohos.bluetooth';
```
......
......@@ -8,7 +8,7 @@ The Brightness module provides an API for setting the screen brightness.
## Modules to Import
```
```js
import brightness from '@ohos.brightness';
```
......@@ -30,6 +30,6 @@ This is a system API and cannot be called by third-party applications.
**Example**
```
```js
brightness.setValue(128);
```
......@@ -39,7 +39,7 @@ Converts an XML text into a JavaScript object.
- Example
```
```js
let xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......
......@@ -5,7 +5,7 @@
## Modules to Import
```
```ts
import deviceInfo from '@ohos.deviceInfo'
```
......
# File Interaction
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
- The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
- The APIs of this module will be deprecated and are not recommended for use. An exception will be thrown if any of the APIs is called.
## Modules to Import
```js
import document from '@ohos.document';
```
## document.choose
choose(type:string[]): Promise&lt;string&gt;
Chooses a file of the specified type using the file manager. This method uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
- Parameters
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------- |
| type | string[] | No | Type of the file to choose.|
- Return value
| Type | Description |
| --------------------- | -------------- |
| Promise&lt;string&gt; | Promise used to return the result. An error code is returned.|
- Example
```js
await document.choose(type);
```
## document.choose
choose(callback:AsyncCallback&lt;string&gt;): void
Chooses a file using the file manager. This method uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
- Parameters
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned.|
- Example
```js
await document.choose(function(err, uri) {
// Do something with the URI.
});
```
## document.choose
choose(type:string[], callback:AsyncCallback&lt;string&gt;): void
Chooses a file of the specified type using the file manager. This method uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
- Parameters
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| type | string[] | No | Type of the file to choose.|
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned.|
- Example
```js
await document.choose(type, function(err, uri) {
// Do something with the URI.
});
```
## document.show
show(url:string, type:string):Promise&lt;number&gt;
Opens a file. This method uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
- Parameters
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ---------------------------- |
| uri | string | Yes | URI of the file to open.|
| type | string | Yes | Type of the file to open.|
- Return value
| Type | Description |
| --------------------- | ------------ |
| Promise&lt;void&gt; | Promise used to return the result. An error code is returned.|
- Example
```js
await document.show(uri, type);
```
## document.show
show(url:string, type:string, callback:AsyncCallback&lt;void&gt;): void
Opens a file. This method uses an asynchronous callback to return the result.
**System capability**: SystemCapability.FileManagement.File.FileIO
- Parameters
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| uri | string | Yes | URI of the file to open.|
| type | string | Yes | Type of the file to open.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. An error code is returned. |
- Example
```js
await document.show(uri, type, function(err) {
//do something
});
```
......@@ -104,7 +104,7 @@ pixelmap.readPixelsToBuffer(readBuffer).then(() => {
readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void
Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses a callback to return the result.
Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image
......@@ -126,7 +126,7 @@ pixelmap.readPixelsToBuffer(readBuffer, () => {
readPixels(area: PositionArea): Promise\<void>
Reads pixel map data in an area. This API uses a promise to return the data read.
Reads image pixel map data in an area. This API uses a promise to return the data read.
**System capability**: SystemCapability.Multimedia.Image
......@@ -156,7 +156,7 @@ pixelmap.readPixels(area).then((data) => {
readPixels(area: PositionArea, callback: AsyncCallback\<void>): void
Reads image pixel map data in an area. This API uses a callback to return the data read.
Reads image pixel map data in an area. This API uses an asynchronous callback to return the data read.
**System capability**: SystemCapability.Multimedia.Image
......@@ -200,7 +200,7 @@ Writes image pixel map data to an area. This API uses a promise to return the op
| Name| Type | Mandatory| Description |
| ------ | ------------------------------ | ---- | -------------------- |
| area | [PositionArea](#positionarea7) | Yes | Area to which the pixel map data will be written.|
| area | [PositionArea](#positionarea7) | Yes | Area to which the image pixel map data will be written.|
**Return value**
......@@ -250,7 +250,7 @@ image.createPixelMap(color, opts)
writePixels(area: PositionArea, callback: AsyncCallback\<void>): void
Writes image pixel map data to an area. This API uses a callback to return the operation result.
Writes image pixel map data to an area. This API uses an asynchronous callback to return the operation result.
**System capability**: SystemCapability.Multimedia.Image
......@@ -258,7 +258,7 @@ Writes image pixel map data to an area. This API uses a callback to return the o
| Name | Type | Mandatory| Description |
| --------- | ------------------------------ | ---- | ------------------------------ |
| area | [PositionArea](#positionarea7) | Yes | Area to which the pixel map data will be written. |
| area | [PositionArea](#positionarea7) | Yes | Area to which the image pixel map data will be written. |
| callback: | AsyncCallback\<void> | Yes | Callback used to return the operation result. If the operation fails, an error message is returned.|
**Example**
......@@ -308,7 +308,7 @@ pixelMap.writeBufferToPixels(colorBuffer).then(() => {
writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\<void>): void
Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** object. This API uses a callback to return the result.
Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image
......@@ -335,7 +335,7 @@ pixelMap.writeBufferToPixels(colorBuffer, function(err) {
getImageInfo(): Promise\<ImageInfo>
Obtains pixel map information about this image. This API uses a promise to return the information.
Obtains pixel map information of this image. This API uses a promise to return the information.
**System capability**: SystemCapability.Multimedia.Image
......@@ -359,7 +359,7 @@ pixelMap.getImageInfo().then(function(info) {
getImageInfo(callback: AsyncCallback\<ImageInfo>): void
Obtains pixel map information about this image. This API uses a callback to return the information.
Obtains pixel map information of this image. This API uses an asynchronous callback to return the information.
**System capability**: SystemCapability.Multimedia.Image
......@@ -379,7 +379,7 @@ pixelmap.getImageInfo((imageInfo) => {})
getBytesNumberPerRow(): number
Obtains the number of bytes in each line of the image pixel map.
Obtains the number of bytes per line of the image pixel map.
**System capability**: SystemCapability.Multimedia.Image
......@@ -387,7 +387,7 @@ Obtains the number of bytes in each line of the image pixel map.
| Type | Description |
| ------ | -------------------- |
| number | Number of bytes in each line.|
| number | Number of bytes per line.|
**Example**
......@@ -440,7 +440,7 @@ Releases this **PixelMap** object. This API uses a promise to return the result.
release(callback: AsyncCallback\<void>): void
Releases this **PixelMap** object. This API uses a callback to return the result.
Releases this **PixelMap** object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image
......@@ -522,7 +522,7 @@ Provides APIs to obtain image information. Before calling any API in **ImageSour
getImageInfo(index: number, callback: AsyncCallback\<ImageInfo>): void
Obtains information about an image with the specified index. This API uses a callback to return the information.
Obtains information about an image with the specified index. This API uses an asynchronous callback to return the information.
**System capability**: SystemCapability.Multimedia.Image
......@@ -543,7 +543,7 @@ imageSourceApi.getImageInfo(0,(error, imageInfo) => {})
getImageInfo(callback: AsyncCallback\<ImageInfo>): void
Obtains information about this image. This API uses a callback to return the information.
Obtains information about this image. This API uses an asynchronous callback to return the information.
**System capability**: SystemCapability.Multimedia.Image
......@@ -620,7 +620,7 @@ imageSourceApi.getImageProperty("BitsPerSample")
getImageProperty(key:string, callback: AsyncCallback\<string>): void
Obtains the value of a property with the specified index in this image. This API uses a callback to return the result.
Obtains the value of a property with the specified index in this image. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image
......@@ -641,7 +641,7 @@ imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {})
getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCallback\<string>): void
Obtains the value of a property in this image. This API uses a callback to return the property value in a string.
Obtains the value of a property in this image. This API uses an asynchronous callback to return the property value in a string.
**System capability**: SystemCapability.Multimedia.Image
......@@ -663,7 +663,7 @@ imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => {})
createPixelMap(options?: DecodingOptions): Promise\<PixelMap>
Creates a **PixelMap** object based on image decoding parameters. This API uses a callback to return the result.
Creates a **PixelMap** object based on image decoding parameters. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Image
......@@ -690,7 +690,7 @@ imageSourceApi.createPixelMap().then(pixelmap => {})
createPixelMap(callback: AsyncCallback\<PixelMap>): void
Creates a **PixelMap** object based on the default parameters. This API uses a callback to return the result.
Creates a **PixelMap** object based on the default parameters. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image
......@@ -710,7 +710,7 @@ imageSourceApi.createPixelMap(pixelmap => {})
createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): void
Creates a **PixelMap** object based on image decoding parameters. This API uses a callback to return the result.
Creates a **PixelMap** object based on image decoding parameters. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image
......@@ -731,7 +731,7 @@ imageSourceApi.createPixelMap(decodingOptions, pixelmap => {})
release(callback: AsyncCallback\<void>): void
Releases this **ImageSource** instance. This API uses a callback to return the result.
Releases this **ImageSource** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image
......@@ -801,7 +801,7 @@ Provide APIs to pack images. Before calling any API in **ImagePacker**, you must
packing(source: ImageSource, option: PackingOption, callback: AsyncCallback<Array\<ArrayBuffer>>): void
Packs an image. This API uses a callback to return the result.
Packs an image. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image
......@@ -854,7 +854,7 @@ imagePackerApi.packing(imageSourceApi, packOpts)
packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\<ArrayBuffer>): void
Packs an image. This API uses a callback to return the result.
Packs an image. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image
......@@ -907,7 +907,7 @@ imagePackerApi.packing(pixelMapApi, packOpts)
release(callback: AsyncCallback\<void>): void
Releases this **ImagePacker** instance. This API uses a callback to return the result.
Releases this **ImagePacker** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image
......@@ -1058,7 +1058,7 @@ Describes the exchangeable image file format (Exif) information of an image.
| Name | Default Value | Description |
| ----------------- | ----------------- | -------------------- |
| BITS_PER_SAMPLE | "BitsPerSample" | Number of bytes in each pixel. |
| BITS_PER_SAMPLE | "BitsPerSample" | Number of bits per pixel. |
| ORIENTATION | "Orientation" | Image orientation. |
| IMAGE_LENGTH | "ImageLength" | Image length. |
| IMAGE_WIDTH | "ImageWidth" | Image width. |
......
......@@ -8,7 +8,7 @@ The Power Manager module provides APIs for rebooting and shutting down the syste
## Modules to Import
```
```js
import power from '@ohos.power';
```
......@@ -35,7 +35,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```
```js
power.shutdownDevice("shutdown_test");
console.info('power_shutdown_device_test success')
```
......@@ -57,7 +57,7 @@ Reboots the system.
**Example**
```
```js
power.rebootDevice("reboot_test");
console.info('power_reboot_device_test success')
```
......@@ -77,7 +77,7 @@ Checks the screen status of the current device.
**Example**
```
```js
power.isScreenOn((error, screenOn) => {
if (typeof error === "undefined") {
console.info('screenOn status is ' + screenOn);
......@@ -101,7 +101,7 @@ Checks the screen status of the current device.
**Example**
```
```js
power.isScreenOn()
.then(screenOn => {
console.info('screenOn status is ' + screenOn);
......
......@@ -60,7 +60,7 @@ Waits until the child process ends. This method uses a promise to return the exi
**Example**
```
```js
var child = process.runCmd('ls');
var result = child.wait();
result.then(val=>{
......@@ -85,7 +85,7 @@ Obtains the standard output of the child process.
**Example**
```
```js
var child = process.runCmd('ls');
var result = child.wait();
child.getOutput.then(val=>{
......@@ -110,7 +110,7 @@ Obtains the standard error output of the child process.
**Example**
```
```js
var child = process.runCmd('madir test.text');
var result = child.wait();
child.getErrorOutput.then(val=>{
......@@ -129,7 +129,7 @@ Closes the child process in running.
**Example**
```
```js
var child = process.runCmd('sleep 5; ls');
child.close();
```
......@@ -151,7 +151,7 @@ Sends a signal to the specified child process to terminate it.
**Example**
```
```js
var child = process.runCmd('sleep 5; ls');
child.kill(9);
```
......@@ -173,7 +173,7 @@ Checks whether this process is isolated.
**Example**
```
```js
var result = process.isIsolatedProcess();
```
......@@ -200,7 +200,7 @@ Checks whether a UID belongs to this app.
**Example**
```
```js
var result = process.isAppUid(688);
```
......@@ -221,7 +221,7 @@ Checks whether this process is running in a 64-bit environment.
**Example**
```
```js
var ressult = process.is64Bit();
```
......@@ -248,7 +248,7 @@ Obtains the process UID based on the process name.
**Example**
```
```js
var pres = process.getUidForName("tool")
```
......@@ -275,7 +275,7 @@ Obtains the thread priority based on the specified TID.
**Example**
```
```js
var tid = process.getTid();
var pres = process.getThreadPriority(tid);
```
......@@ -297,7 +297,7 @@ Obtains the duration, in milliseconds, from the time the system starts to the ti
**Example**
```
```js
var realtime = process.getStartRealtime();
```
......@@ -317,7 +317,7 @@ Obtains the CPU time (in milliseconds) from the time the process starts to the c
**Example**
```
```js
var result = process.getPastCpuTime() ;
```
......@@ -344,7 +344,7 @@ Obtains the system configuration.
**Example**
```
```js
var _SC_ARG_MAX = 0
var pres = process.getSystemConfig(_SC_ARG_MAX)
```
......@@ -372,7 +372,7 @@ Obtains the value of an environment variable.
**Example**
```
```js
var pres = process.getEnvironmentVar("PATH")
```
......@@ -408,7 +408,7 @@ Forks a new process to run a shell command and returns the **ChildProcess** obje
**Example**
```
```js
var child = process.runCmd('ls', { maxBuffer : 2 });
var result = child.wait();
child.getOutput.then(val=>{
......@@ -427,7 +427,7 @@ Aborts a process and generates a core file. This method will cause a process to
**Example**
```
```js
process.abort();
```
......@@ -455,7 +455,7 @@ Stores the events triggered by the user.
**Example**
```
```js
process.on("data", (e)=>{
console.log("data callback");
})
......@@ -484,7 +484,7 @@ Deletes the event stored by the user.
**Example**
```
```js
process.on("data", (e)=>{
console.log("data callback");
})
......@@ -510,7 +510,7 @@ Exercise caution when using this API.
**Example**
```
```js
process.exit(0);
```
......@@ -525,7 +525,7 @@ Obtains the working directory of this process.
**Example**
```
```js
var path = process.cwd();
```
......@@ -546,7 +546,7 @@ Changes the working directory of this process.
**Example**
```
```js
process.chdir('/system');
```
......@@ -567,7 +567,7 @@ Obtains the running time of this process.
**Example**
```
```js
var time = process.uptime();
```
......@@ -594,7 +594,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(pres, 28)
```
......@@ -8,7 +8,7 @@
## Modules to Import
```
```js
import screenlock from '@ohos.screenLock';
```
......@@ -28,7 +28,7 @@ Checks whether the screen is locked. This method uses an asynchronous callback t
- Example
```
```js
screenlock.isScreenLocked((err, data)=>{
if (err) {
console.error('isScreenLocked callback error -> ${JSON.stringify(err)}');
......@@ -54,7 +54,7 @@ Checks whether the screen is locked. This method uses a promise to return the re
- Example
```
```js
screenlock.isScreenLocked().then((data) => {
console.log('isScreenLocked success: data -> ${JSON.stringify(data)}');
}).catch((err) => {
......@@ -81,7 +81,7 @@ Checks whether a device is in secure mode. This method uses an asynchronous call
- Example
```
```js
screenlock.isSecureMode((err, data)=>{
if (err) {
console.error('isSecureMode callback error -> ${JSON.stringify(err)}');
......@@ -107,7 +107,7 @@ Checks whether a device is in secure mode. This method uses a promise to return
- Example
```
```js
screenlock.isSecureMode().then((data) => {
console.log('isSecureMode success: data->${JSON.stringify(data)}');
}).catch((err) => {
......@@ -134,7 +134,7 @@ Unlocks the screen. This method uses an asynchronous callback to return the resu
- Example
```
```js
screenlock.unlockScreen((err)=>{
if (err) {
console.error('unlockScreen callback error -> ${JSON.stringify(err)}');
......@@ -160,7 +160,7 @@ Unlocks the screen. This method uses a promise to return the result.
- Example
```
```js
screenlock.unlockScreen().then(() => {
console.log('unlockScreen success');
}).catch((err) => {
......
......@@ -9,7 +9,7 @@ This module provides APIs for setting data items.
## Modules to Import
```
```typescript
import settings from '@ohos.settings';
```
......@@ -34,7 +34,7 @@ Obtains the URI of a data item.
| string | URI of the data item.|
- Example
```
```typescript
// Obtain the URI of a data item.
let urivar = settings.getUriSync('settings.screen.brightness');
```
......@@ -61,7 +61,7 @@ Obtains the value of a data item.
| string | Value of the data item.|
- Example
```
```typescript
import featureAbility from '@ohos.featureAbility';
// Obtain the value of 'settings.screen.brightness' (this data item already exists in the database).
......@@ -96,7 +96,7 @@ If the specified data item exists in the database, the **setValueSync** method u
| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
- Example
```
```typescript
import featureAbility from '@ohos.featureAbility';
// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync
......
......@@ -138,7 +138,7 @@ Sets the maximum size (in bytes) of the image data cached in the memory before d
export default {
onCreate() {
app.setImageRawDataCacheSize(104,857,600) // Set the upper limit of the memory for caching image data before decoding to 100 MB.
app.setImageRawDataCacheSize(100) // Set the upper limit of the memory for caching image data before decoding to 100 MB.
console.info('Application onCreate')
},
onDestroy() {
......@@ -168,7 +168,7 @@ Sets the maximum size of the image file cache (in bytes) to speed up the loading
export default {
onCreate() {
app.setImageFileCacheSize(209,715,200) // Set the upper limit of the image file cache to 200 MB.
app.setImageFileCacheSize(200) // Set the upper limit of the image file cache to 200 MB.
console.info('Application onCreate')
},
onDestroy() {
......
......@@ -9,7 +9,7 @@
## Modules to Import
```
```js
import battery from '@system.battery';
```
......@@ -39,7 +39,7 @@ The following value will be returned when the check result is obtained.
**Example**
```
```js
export default {
getStatus() {
battery.getStatus({
......
......@@ -9,7 +9,7 @@
## Modules to Import
```
```js
import brightness from '@system.brightness';
```
......@@ -38,7 +38,7 @@ The following values will be returned when the operation is successful.
**Example**
```
```js
export default {
getValue() {
brightness.getValue({
......@@ -73,7 +73,7 @@ Sets the screen brightness.
**Example**
```
```js
export default {
setValue() {
brightness.setValue({
......@@ -114,7 +114,7 @@ The following values will be returned when the operation is successful.
**Example**
```
```js
export default {
getMode() {
brightness.getMode({
......@@ -149,7 +149,7 @@ Sets the screen brightness adjustment mode.
**Example**
```
```js
export default {
setMode() {
brightness.setMode({
......@@ -185,7 +185,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**.
**Example**
```
```js
export default {
setKeepScreenOn() {
brightness.setKeepScreenOn({
......
......@@ -6,7 +6,7 @@
## Modules to Import
```
```ts
import parameter from '@ohos.systemParameter'
```
......@@ -34,7 +34,7 @@ Obtains the value of the attribute with the specified key.
**Example**
```
```ts
try {
var info = parameter.getSync("test.parameter.key");
console.log(JSON.stringify(info));
......@@ -61,7 +61,7 @@ Obtains the value of the attribute with the specified key. This API uses an asyn
**Example**
```
```ts
try {
parameter.get("test.parameter.key", function (err, data) {
if (err == undefined) {
......@@ -93,7 +93,7 @@ Obtains the value of the attribute with the specified key. This API uses an asyn
**Example**
```
```ts
try {
parameter.get("test.parameter.key", "default", function (err, data) {
if (err == undefined) {
......@@ -131,7 +131,7 @@ Obtains the value of the attribute with the specified key. This API uses a promi
**Example**
```
```ts
try {
var p = parameter.get("test.parameter.key");
p.then(function (value) {
......@@ -162,7 +162,7 @@ Sets a value for the attribute with the specified key.
**Example**
```
```ts
try {
parameter.setSync("test.parameter.key", "default");
}catch(e){
......@@ -189,7 +189,7 @@ Sets a value for the attribute with the specified key. This API uses an asynchro
**Example**
```
```ts
try {
parameter.set("test.parameter.key", "testValue", function (err, data) {
if (err == undefined) {
......@@ -226,7 +226,7 @@ Sets a value for the attribute with the specified key. This API uses a promise t
**Example**
```
```ts
try {
var p = para.set("test.parameter.key", "testValue");
p.then(function (value) {
......
......@@ -8,7 +8,7 @@ This module provides thermal level-related callback and query APIs to obtain the
## Modules to Import
```
```js
import thermal from '@ohos.thermal';
```
......@@ -46,7 +46,7 @@ Subscribes to thermal level changes.
**Example**
```
```js
var lev = 0;
thermal.subscribeThermalLevel((lev) => {
console.info("Thermal level is: " + lev);
......@@ -69,7 +69,7 @@ Unsubscribes from thermal level changes.
**Example**
```
```js
thermal.unsubscribeThermalLevel(() => {
console.info("Unsubscribe completed.");
});
......@@ -91,7 +91,7 @@ Obtains the current thermal level.
**Example**
```
```js
var lev = thermal.getThermalLevel();
console.info("Thermal level is: " + lev);
```
......@@ -46,11 +46,11 @@ A constructor used to create a URI instance.
**Example**
```
```js
var mm = 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment';
new uri.URI(mm); // Output 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment';
```
```
```js
new uri.URI('http://username:password@host:8080'); // Output 'http://username:password@host:8080';
```
......@@ -69,7 +69,7 @@ Obtains the query string applicable to this URL.
**Example**
```
```js
const url = new uri.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toString()
```
......@@ -95,7 +95,7 @@ Checks whether this URI is the same as another URI object.
**Example**
```
```js
const uriInstance = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
const uriInstance1 = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da#fragment');
uriInstance.equals(uriInstance1);
......@@ -115,7 +115,7 @@ Checks whether this URI is an absolute URI (whether the scheme component is defi
**Example**
```
```js
const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080?query=pppppp');
uriInstance.checkIsAbsolute();
```
......@@ -134,7 +134,7 @@ Normalizes the path of this URI.
| URI | URI with the normalized path.|
**Example**
```
```js
const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp');
let uriInstance1 = uriInstance.normalize();
uriInstance1.path;
......
......@@ -31,7 +31,7 @@ Creates a **URLSearchParams** instance.
**Example**
```
```js
var objectParams = new URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]);
var objectParams1 = new URLSearchParams({"fod" : 1 , "bard" : 2});
var objectParams2 = new URLSearchParams('?fod=1&bard=2');
......@@ -55,7 +55,7 @@ Appends a key-value pair into the query string.
**Example**
```
```js
let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new URLSearchParams(urlObject.search.slice(1));
paramsObject.append('fod', 3);
......@@ -76,7 +76,7 @@ Deletes key-value pairs of the specified key.
**Example**
```
```js
let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsobject = new URLSearchParams(urlObject.search.slice(1));
paramsobject.delete('fod');
......@@ -103,7 +103,7 @@ Obtains all the key-value pairs based on the specified key.
**Example**
```
```js
let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new URLSearchParams(urlObject.search.slice(1));
paramsObject.append('fod', 3); // Add a second value for the fod parameter.
......@@ -125,7 +125,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th
**Example**
```
```js
var searchParamsObject = new URLSearchParams("keyName1=valueName1&keyName2=valueName2");
for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs
console.log(pair[0]+ ', '+ pair[1]);
......@@ -156,7 +156,7 @@ Traverses the key-value pairs in the **URLSearchParams** instance by using a cal
**Example**
```
```js
const myURLObject = new URL('https://developer.exampleUrl/?fod=1&bard=2');
myURLObject.searchParams.forEach((value, name, searchParams) => {
console.log(name, value, myURLObject.searchParams === searchParams);
......@@ -185,7 +185,7 @@ Obtains the value of the first key-value pair based on the specified key.
**Example**
```
```js
var paramsOject = new URLSearchParams(document.location.search.substring(1));
var name = paramsOject.get("name"); // is the string "Jonathan"
var age = parseInt(paramsOject.get("age"), 10); // is the number 18
......@@ -213,7 +213,7 @@ Checks whether a key has a value.
**Example**
```
```js
let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new URLSearchParams(urlObject.search.slice(1));
paramsObject.has('bard') === true;
......@@ -235,7 +235,7 @@ Sets the value for a key. If key-value pairs matching the specified key exist, t
**Example**
```
```js
let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2');
let paramsObject = new URLSearchParams(urlObject.search.slice(1));
paramsObject.set('baz', 3); // Add a third parameter.
......@@ -251,7 +251,7 @@ Sorts all key-value pairs contained in this object based on the Unicode code poi
**Example**
```
```js
var searchParamsObject = new URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object
searchParamsObject.sort(); // Sort the key/value pairs
console.log(searchParamsObject.toString()); // Display the sorted query string // Output a=9&b=2&c=3&d=4
......@@ -273,7 +273,7 @@ Obtains an ES6 iterator that contains the keys of all the key-value pairs.
**Example**
```
```js
var searchParamsObject = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing
for (var key of searchParamsObject .keys()) { // Output key-value pairs
console.log(key);
......@@ -295,7 +295,7 @@ Obtains an ES6 iterator that contains the values of all the key-value pairs.
**Example**
```
```js
var searchParams = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing
for (var value of searchParams.values()) {
console.log(value);
......@@ -318,7 +318,7 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th
**Example**
```
```js
const paramsObject = new URLSearchParams('fod=bay&edg=bap');
for (const [name, value] of paramsObject) {
console.log(name, value);
......@@ -341,7 +341,7 @@ Obtains search parameters that are serialized as a string and, if necessary, per
**Example**
```
```js
let url = new URL('https://developer.exampleUrl/?fod=1&bard=2');
let params = new URLSearchParams(url.search.slice(1));
params.append('fod', 3);
......@@ -386,7 +386,7 @@ Creates a URL.
**Example**
```
```js
var mm = 'http://username:password@host:8080';
var a = new URL("/", mm); // Output 'http://username:password@host:8080/';
var b = new URL(mm); // Output 'http://username:password@host:8080/';
......@@ -416,7 +416,7 @@ Converts the parsed URL into a string.
**Example**
```
```js
const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toString()
```
......@@ -436,7 +436,7 @@ Converts the parsed URL into a JSON string.
| string | Website address in a serialized string.|
**Example**
```
```js
const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toJSON()
```
......@@ -32,7 +32,7 @@ A constructor used to create an **XmlSerializer** instance.
**Example**
```
```js
var arrayBuffer = new ArrayBuffer(1024);
var bufView = new DataView(arrayBuffer);
var thatSer = new xml.XmlSerializer(bufView);
......@@ -54,7 +54,7 @@ Sets an attribute.
**Example**
```
```js
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setAttributes("importance", "high");
```
......@@ -74,8 +74,8 @@ Adds an empty element.
**Example**
```
var thatSer = new xml.XmlSerializer(bufView);
```js
var thatSer = new xml.XmlSerializer(bufView);
thatSer.addEmptyElement("b"); // => <b/>
```
......@@ -88,7 +88,7 @@ Sets a declaration.
**Example**
```
```js
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setDeclaration() // => <?xml version="1.0" encoding="utf-8"?>;
```
......@@ -108,7 +108,7 @@ Writes the start tag based on the given element name.
**Example**
```
```js
var arrayBuffer = new ArrayBuffer(1024);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("notel");
......@@ -124,7 +124,7 @@ Writes the end tag of the element.
**Example**
```
```js
var thatSer = new xml.XmlSerializer(bufView);
thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
thatSer.startElement("table");
......@@ -149,7 +149,7 @@ Sets the namespace for an element tag.
**Example**
```
```js
var arrayBuffer = new ArrayBuffer(1024);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setDeclaration();
......@@ -172,7 +172,7 @@ Sets the comment.
**Example**
```
```js
var arrayBuffer = new ArrayBuffer(1024);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
......@@ -195,7 +195,7 @@ Sets CDATA attributes.
**Example**
```
```js
var arrayBuffer = new ArrayBuffer(1028);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setCDATA('root SYSTEM') // => '<![CDATA[root SYSTEM]]>';
......@@ -216,7 +216,7 @@ Sets **Text**.
**Example**
```
```js
var arrayBuffer = new ArrayBuffer(1024);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
......@@ -240,7 +240,7 @@ Sets **DocType**.
**Example**
```
```js
var arrayBuffer = new ArrayBuffer(1024);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setDocType('root SYSTEM'); // => '<!DOCTYPE root SYSTEM>';
......@@ -265,7 +265,7 @@ Creates and returns an **XmlPullParser** object. The **XmlPullParser** object pa
**Example**
```
```js
var strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -297,7 +297,7 @@ Parses XML information.
**Example**
```
```js
var strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......
......@@ -29,7 +29,7 @@ Touch target configuration is not supported.
| Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- |
| tabBar | string \| {<br/>icon?: string,<br/>text?: string<br/>}<br/>\|[CustomBuilder](../../ui/ts-types.md) | - | Content displayed on the tab bar.<br/>**CustomBuilder**: builder, to which components can be passed (applicable to API version 8 and later versions).<br/>> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>> If an icon uses an SVG image, the width and height attributes of the SVG image must be deleted. Otherwise, the icon size will be determined by the width and height attributes of the SVG image. |
| tabBar | string \| {<br/>icon?: string,<br/>text?: string<br/>}<br/>\| [CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | Content displayed on the tab bar.<br/>**CustomBuilder**: builder, to which components can be passed (applicable to API version 8 and later versions).<br/>> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>> If an icon uses an SVG image, the width and height attributes of the SVG image must be deleted. Otherwise, the icon size will be determined by the width and height attributes of the SVG image. |
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> - The **&lt;TabContent&gt;** component does not support setting of the common width attribute. By default, its width is the same as that of the parent **&lt;Tabs&gt;** component.
......
......@@ -11,7 +11,7 @@ You can create a button by invoking either of the following APIs:
- Button(options?: {type?: ButtonType, stateEffect?: boolean})
This API creates a button that contains child components. In the syntax, **type** indicates the button type, and **stateEffect** indicates whether to enable the click effect for the button.
```
Button({ type: ButtonType.Normal, stateEffect: true }) {
Row() {
......@@ -26,7 +26,7 @@ You can create a button by invoking either of the following APIs:
- Button(label?: string, options?: { type?: ButtonType, stateEffect?: boolean })
This API creates a button that does not contain any child components. In the syntax, **label** indicates whether the created button contains child components.
```
Button('Ok', { type: ButtonType.Normal, stateEffect: true })
.borderRadius(8)
......@@ -42,7 +42,7 @@ You can create a button by invoking either of the following APIs:
Use the **type** parameter to set the button type to **Capsule**, **Circle**, or **Normal**.
- Capsule button (default type)
```
Button('Disable', { type: ButtonType.Capsule, stateEffect: false })
.backgroundColor(0x317aff)
......@@ -52,7 +52,7 @@ Use the **type** parameter to set the button type to **Capsule**, **Circle**, or
![en-us_image_0000001215645452](figures/en-us_image_0000001215645452.png)
- Circle button
```
Button('Circle', { type: ButtonType.Circle, stateEffect: false })
.backgroundColor(0x317aff)
......@@ -68,18 +68,18 @@ Use the **type** parameter to set the button type to **Capsule**, **Circle**, or
- Set the border radius:
In general cases, you can use universal attributes to define the button styles. For example, you can use the **borderRadius** attribute to set the border radius.
```
Button('circle border', { type: ButtonType.Normal })
.borderRadius(20)
```
![zh-cn_image_0000001190463780](figures/zh-cn_image_0000001190463780.png)
![en-us_image_0000001215645452](figures/en-us_image_0000001215645452.png)
- Setting Text Styles
Add a font style for text displayed on the button.
```
Button('font style', { type: ButtonType.Normal })
.fontSize(20)
......@@ -87,12 +87,12 @@ Use the **type** parameter to set the button type to **Capsule**, **Circle**, or
.fontWeight(800)
```
![zh-cn_image_0000001189744672](figures/zh-cn_image_0000001189744672.png)
![en-us_image_0000001215965420](figures/en-us_image_0000001215965420.png)
- Set the background color:
You can do so by adding the **backgroundColor** attribute.
```
Button('background color').backgroundColor(0xF55A42)
```
......@@ -102,7 +102,7 @@ Use the **type** parameter to set the button type to **Capsule**, **Circle**, or
- Assign a function to the button:
In this example, we are creating a button with the delete function.
```
Button({ type: ButtonType.Circle, stateEffect: true }) {
Image($r('app.media.ic_public_delete_filled')).width(30).height(30)
......@@ -133,7 +133,7 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true })
```
import router from '@ohos.router'
@Entry
@Component
struct ButtonCase1 {
......@@ -144,13 +144,13 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true })
router.push({ url: 'xxx' })
})
}
ListItem() {
Button("Second").onClick(() => {
router.push({ url: 'yyy' })
})
}
ListItem() {
Button("Third").onClick(() => {
router.push({ url: 'zzz' })
......@@ -170,7 +170,7 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true })
- Using the Button for Submitting Forms
On the user login/registration page, you can use a button to submit a login or registration request.
```
@Entry
@Component
......@@ -184,5 +184,5 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true })
}
}
```
![en-us_image_0000001190466492](figures/en-us_image_0000001190466492.png)
......@@ -45,9 +45,9 @@ screen and (device-type: tv) or (resolution &lt; 2) // This is a multi-condition
### media-type
| Type| Description|
| -------- | -------- |
| screen | Media query based on screen-related parameters.|
| Type | Description |
| ------ | ---------------------------------------- |
| screen | Media query based on screen-related parameters. |
### Media Logic Operation (and|not|only)
......@@ -56,48 +56,48 @@ You can use logical operators (**and**, **or**, **not**, and **only**) to compos
**Table 1** Media logical operators
| Type| Description|
| -------- | -------- |
| and | The **and** operator is used to combine multiple media features into one media query, in a logical AND operation. The query is valid only when all media features are true. It can also combine media types and media functions.<br>For example, **screen&nbsp;and&nbsp;(device-type:&nbsp;wearable)&nbsp;and&nbsp;(max-height:&nbsp;600)&nbsp;** indicates that the query is valid when the device type is wearable and the maximum height of the application is 600 pixel units.|
| not | The **not** operator is used to perform a logical negation for a media query. **true** is returned if the query condition is not met. Otherwise, **false** is returned. In a media query list, logical negation is performed only for the media query using the **not** operator.<br>For example, **not&nbsp;screen&nbsp;and&nbsp;(min-height:&nbsp;50)&nbsp;and&nbsp;(max-height:&nbsp;600)&nbsp;** indicates that the query is valid when the height of the application is less than 50 pixel units or greater than 600 pixel units.<br>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**NOTE**<br>>&nbsp;When the **not** operator is used, the media type must be specified.|
| only | The **only** operator applies the selected style only when the entire expression is matched. It can be used to prevent ambiguity on browsers of earlier versions. The statements that contain both media types and media features produce ambiguity when they are received by some browsers of earlier versions. For example:<br>screen&nbsp;and&nbsp;(min-height:&nbsp;50)<br>The browsers of earlier versions would mislead this sentence into screen, causing the fact that the specified style is applied when only the media type is matched. In this case, the **only** operator can be used to avoid this problem.<br>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**NOTE**<br>>&nbsp;When the **only** operator is used, the media type must be specified.|
| ,(comma) | The **or** operator is used to combine multiple media features into one media query, in a logical OR operation. The query is valid if a media feature is true. The effect of a comma operator is equivalent to that of the **or** operator.<br>For example, **screen&nbsp;and&nbsp;(min-height:&nbsp;1000),&nbsp;&nbsp;(round-screen: true)&nbsp;** indicates that the query is valid when the minimum height of the application is 1000 pixel units or the device screen is round.|
| or | The **or** operator is used to combine multiple media features into one media query, in a logical OR operation. The query is valid if a media feature is true.<br>For example, **screen&nbsp;and&nbsp;(max-height:&nbsp;1000)&nbsp;or&nbsp;&nbsp;(round-screen: true)** indicates that the query is valid when the maximum height of the application is 1000 pixel units or the device screen is round.|
| Type | Description |
| -------- | ---------------------------------------- |
| and | The **and** operator is used to combine multiple media features into one media query, in a logical AND operation. The query is valid only when all media features are true. It can also combine media types and media functions.<br>For example, **screen&nbsp;and&nbsp;(device-type:&nbsp;wearable)&nbsp;and&nbsp;(max-height:&nbsp;600)&nbsp;** indicates that the query is valid when the device type is wearable and the maximum height of the application is 600 pixel units. |
| not | The **not** operator is used to perform a logical negation for a media query. **true** is returned if the query condition is not met. Otherwise, **false** is returned. In a media query list, logical negation is performed only for the media query using the **not** operator.<br>For example, **not&nbsp;screen&nbsp;and&nbsp;(min-height:&nbsp;50)&nbsp;and&nbsp;(max-height:&nbsp;600)&nbsp;** indicates that the query is valid when the height of the application is less than 50 pixel units or greater than 600 pixel units.<br>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**NOTE**<br>>&nbsp;When the **not** operator is used, the media type must be specified. |
| only | The **only** operator applies the selected style only when the entire expression is matched. It can be used to prevent ambiguity on browsers of earlier versions. The statements that contain both media types and media features produce ambiguity when they are received by some browsers of earlier versions. For example:<br>screen&nbsp;and&nbsp;(min-height:&nbsp;50)<br>The browsers of earlier versions would mislead this sentence into screen, causing the fact that the specified style is applied when only the media type is matched. In this case, the **only** operator can be used to avoid this problem.<br>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**NOTE**<br>>&nbsp;When the **only** operator is used, the media type must be specified. |
| ,(comma) | The **or** operator is used to combine multiple media features into one media query, in a logical OR operation. The query is valid if a media feature is true. The effect of a comma operator is equivalent to that of the **or** operator.<br>For example, **screen&nbsp;and&nbsp;(min-height:&nbsp;1000),&nbsp;&nbsp;(round-screen: true)&nbsp;** indicates that the query is valid when the minimum height of the application is 1000 pixel units or the device screen is round. |
| or | The **or** operator is used to combine multiple media features into one media query, in a logical OR operation. The query is valid if a media feature is true.<br>For example, **screen&nbsp;and&nbsp;(max-height:&nbsp;1000)&nbsp;or&nbsp;&nbsp;(round-screen: true)** indicates that the query is valid when the maximum height of the application is 1000 pixel units or the device screen is round. |
At MediaQuery Level 4, range query is imported so that you can use the operators including &lt;=, &gt;=, &lt;, and &gt; besides the **max-** and **min-** operators.
**Table 2** Logical operators for range query
| Type| Description|
| -------- | -------- |
| &lt;= | Less than or equal to, for example, **screen&nbsp;and&nbsp;(50&nbsp;&lt;=&nbsp;height)**.|
| &gt;= | Greater than or equal to, for example, **screen&nbsp;and&nbsp;(600&nbsp;&gt;=&nbsp;height)**.|
| &lt; | Less than, for example, **screen&nbsp;and&nbsp;(50&nbsp;&lt;&nbsp;height)**.|
| &gt; | Greater than, for example, **screen&nbsp;and&nbsp;(600&nbsp;&gt;&nbsp;height)**.|
| Type | Description |
| ----- | ---------------------------------------- |
| &lt;= | Less than or equal to, for example, **screen&nbsp;and&nbsp;(50&nbsp;&lt;=&nbsp;height)**. |
| &gt;= | Greater than or equal to, for example, **screen&nbsp;and&nbsp;(600&nbsp;&gt;=&nbsp;height)**. |
| &lt; | Less than, for example, **screen&nbsp;and&nbsp;(50&nbsp;&lt;&nbsp;height)**. |
| &gt; | Greater than, for example, **screen&nbsp;and&nbsp;(600&nbsp;&gt;&nbsp;height)**. |
### media-feature
| Type| Description|
| -------- | -------- |
| height | Height of the display area on the application page.|
| min-height | Minimum height of the display area on the application page.|
| max-height | Maximum height of the display area on the application page.|
| width | Width of the display area on the app page.|
| min-width | Minimum width of the display area on the application page.|
| max-width | Maximum width of the display area on the application page.|
| resolution | Resolution of the device. The unit can be dpi, dppx, or dpcm.<br>-&nbsp;**dpi** indicates the number of physical pixels per inch. 1 dpi ≈ 0.39 dpcm.<br>-&nbsp;**dpcm** indicates the number of physical pixels per centimeter. 1 dpcm&nbsp;&nbsp;2.54 dpi.<br>-&nbsp;**dppx** indicates the number of physical pixels in each pixel. (This unit is calculated based on this formula: 96 px = 1 inch, which is different from the calculation method of the px unit on the page.) 1 dppx&nbsp;=&nbsp;96 dpi.|
| min-resolution | Minimum device resolution.|
| max-resolution | Maximum device resolution.|
| orientation | Screen orientation.<br>Options are as follows:<br>-&nbsp;orientation:&nbsp;portrait<br>-&nbsp;orientation:&nbsp;landscape|
| device-height | Height of the device.|
| min-device-height | Minimum height of the device.|
| max-device-height | Maximum height of the device.|
| device-width | Width of the device.|
| min-device-width | Minimum width of the device.|
| max-device-width | Maximum width of the device.|
| round-screen | Screen type. The value **true** means that the screen is round, and **false** means the opposite.|
| dark-mode | Whether the device is in dark mode. The value **true** means that the device is in dark mode, and **false** means the opposite.|
| Type | Description |
| ----------------- | ---------------------------------------- |
| height | Height of the display area on the application page. |
| min-height | Minimum height of the display area on the application page. |
| max-height | Maximum height of the display area on the application page. |
| width | Width of the display area on the app page. |
| min-width | Minimum width of the display area on the application page. |
| max-width | Maximum width of the display area on the application page. |
| resolution | Resolution of the device. The unit can be dpi, dppx, or dpcm.<br>-&nbsp;**dpi** indicates the number of physical pixels per inch. 1 dpi ≈ 0.39 dpcm.<br>-&nbsp;**dpcm** indicates the number of physical pixels per centimeter. 1 dpcm&nbsp;&nbsp;2.54 dpi.<br>-&nbsp;**dppx** indicates the number of physical pixels in each pixel. (This unit is calculated based on this formula: 96 px = 1 inch, which is different from the calculation method of the px unit on the page.) 1 dppx&nbsp;=&nbsp;96 dpi. |
| min-resolution | Minimum device resolution. |
| max-resolution | Maximum device resolution. |
| orientation | Screen orientation.<br>Options are as follows:<br>-&nbsp;orientation:&nbsp;portrait<br>-&nbsp;orientation:&nbsp;landscape |
| device-height | Height of the device. |
| min-device-height | Minimum height of the device. |
| max-device-height | Maximum height of the device. |
| device-width | Width of the device. |
| min-device-width | Minimum width of the device. |
| max-device-width | Maximum width of the device. |
| round-screen | Screen type. The value **true** means that the screen is round, and **false** means the opposite. |
| dark-mode | Whether the device is in dark mode. The value **true** means that the device is in dark mode, and **false** means the opposite. |
## Example Scenario
......@@ -139,7 +139,7 @@ Use media queries to apply different content and styles to the page text when th
}
```
When the device is in landscape orientation, the text content is displayed in landscape mode in the color of #FFD700.<br/>
![zh-cn_image_0000001262954829](figures/zh-cn_image_0000001262954829.png)
![en-us_image_0000001262954829](figures/en-us_image_0000001262954829.png)
When the device is not in landscape orientation, the text content is displayed in portrait mode in the color of #DB7093.<br/>
![en-us_image_0000001263074739](figures/en-us_image_0000001263074739.png)
......@@ -556,7 +556,7 @@
- [@ohos.data.distributedData](reference/apis/js-apis-distributed-data.md)
- [@ohos.data.distributedDataObject](reference/apis/js-apis-data-distributedobject.md)
- [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md)
- [@ohos.data.storage](reference/apis/js-apis-data-storage.md)
- [@ohos.data.storage](reference/apis/js-apis-data-storage.md)
- [@ohos.settings](reference/apis/js-apis-settings.md)
- [resultSet](reference/apis/js-apis-data-resultset.md)
......
# Use Case<a name="EN-US_TOPIC_0000001055686082"></a>
- For details about the development board, compilation, burning, and image running, see [Hi3518 Development Board](../quick-start/quickstart-lite-introduction-hi3518.md#section14815247616). A compilation result file of sample code is stored in **out/ipcamera\_hi3518ev300/dev\_tools/bin/camera\_sample**. You can copy the file to a TF card, or modify the compilation script of **camera\_sample** to copy the result to **rootfs.img**.
- A Hi318 compilation result file of sample code is stored in **out/ipcamera\_hi3518ev300/dev\_tools/bin/camera\_sample**. You can copy the file to a TF card, or modify the compilation script of **camera\_sample** to copy the result to **rootfs.img**.
Modify **output\_dir** in **applications/sample/camera/media/BUILD.gn**.
......
......@@ -97,7 +97,7 @@ Based on the Hi3861 platform, the OpenHarmony WLAN module provides abundant peri
## Verification<a name="section1949121910344"></a>
For details about the compilation and burning processes, see [Building Source Code](../quick-start/quickstart-lite-steps-hi3861-connection.md#section191121332125319) and [Burning Images](../quick-start/quickstart-lite-steps-hi3861-connection.md#section3288165814218) in the _Getting Started with Hi3861_.
For details about the compilation and burning processes, see [Building Source Code](../quick-start/quickstart-ide-lite-steps-hi3861-building.md) and [Burning Images](../quick-start/quickstart-ide-lite-steps-hi3861-burn.md) in the _Getting Started with Hi3861_.
After the preceding two steps are complete, press the **RST** button to reset the module. If the LED blinks periodically as expected, the verification is passed.
......
......@@ -12,7 +12,7 @@ To accommodate different developer habits, OpenHarmony provides two modes for ge
- Installation package mode: Dependency download and installation as well as building operations are performed using commands. Burning and running are performed in DevEco Device Tool.
OpenHarmony also provides the [Docker environment](../get-code/gettools-acquire.md), which can significantly simplify the environment configuration before compilation. You can build your source code in the Docker environment if you are more accustomed to using the installation package mode.
This document exemplifies how to use the IDE mode. For details about the installation package mode, see [Getting Started with Mini and Small Systems (Installation Package Mode)](../quick-start/quickstart-lite-package-directory.md).
This document exemplifies how to use the IDE mode. For details about the installation package mode, see [Getting Started with Mini and Small Systems (Installation Package Mode)](../quick-start/quickstart-lite-overview.md).
## Development Environment
......@@ -28,7 +28,7 @@ This document describes how to develop OpenHarmony in the Windows+Ubuntu environ
## Development Boards
In this document, two development board models are used as examples: Hi3861 and Hi3516D V300. For details about these development boards, see [Appendix](../quick-start/quickstart-ide-lite-board-introduction.md). You can purchase the development board as required.
In this document, two development board models are used as examples: Hi3861 and Hi3516D V300. For details about these development boards, see [Appendix](../quick-start/quickstart-ide-lite-introduction-hi3861.md). You can purchase the development board as required.
## Development Process
......
......@@ -12,7 +12,7 @@ To accommodate different developer habits, OpenHarmony provides two modes for ge
- Installation package mode: Dependency download and installation as well as building operations are performed using commands. Burning and running are performed in DevEco Device Tool.
OpenHarmony also provides the [Docker environment](../get-code/gettools-acquire.md), which can significantly simplify the environment configuration before compilation. You can build your source code in the Docker environment if you are more accustomed to using the installation package mode.
This document exemplifies how to use the IDE mode. For details about the installation package mode, see [Getting Started with Standard System (Installation Package Mode)](../quick-start/quickstart-standard-package-directory.md).
This document exemplifies how to use the IDE mode. For details about the installation package mode, see [Getting Started with Standard System (Installation Package Mode)](../quick-start/quickstart-standard-overview.md).
## Development Environment
......@@ -28,7 +28,7 @@ This document describes how to develop OpenHarmony in the Windows+Ubuntu environ
## Development Boards
In this document, two development board models are used as examples: Hi3516D V300 and RK3568. For details about these development boards, see [Appendix](../quick-start/quickstart-standard-board-introduction.md). You can purchase the development board as required.
In this document, two development board models are used as examples: Hi3516D V300 and RK3568. For details about these development boards, see [Appendix](../quick-start/quickstart-ide-standard-board-introduction-hi3516.md). You can purchase the development board as required.
## Development Process
......
......@@ -7,9 +7,9 @@
Error: Opening COMxx: Access denied is displayed after clicking Burn and selecting a serial port.
**Figure 1** Failed to open the serial port
**Figure 1** Failed to open the serial port
![en-us_image_0000001226634728](figures/en-us_image_0000001226634728.png)
![en-us_image_0000001226634728](figures/en-us_image_0000001226634728.png)
- **Possible Causes**
......@@ -42,9 +42,9 @@
The file image cannot be obtained after clicking Burn and selecting a serial port.
**Figure 5** Failed to obtain the file image due to network disconnection
**Figure 5** Failed to obtain the file image due to network disconnection
![en-us_image_0000001271234757](figures/en-us_image_0000001271234757.png)
![en-us_image_0000001271234757](figures/en-us_image_0000001271234757.png)
- **Possible Causes**
......@@ -125,15 +125,12 @@
1. Obtain the U-Boot file.
> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE**
> The U-Boot file of the two boards can be obtained from the following paths, respectively.
>
> Hi3516D V300: device\hisilicon\hispark_taurus\sdk_liteos\uboot\out\boot\u-boot-hi3516dv300.bin
>
> Hi3518E V300: device\hisilicon\hispark_aries\sdk_liteos\uboot\out\boot\u-boot-hi3518ev300.bin
>
> The U-Boot file can be obtained from the following path: device\hisilicon\hispark_taurus\sdk_liteos\uboot\out\boot\u-boot-hi3516dv300.bin.
2. Burn the U-Boot file by following the procedures for burning a U-Boot file over USB.
Select the U-Boot files of corresponding development boards for burning by referring to [Burning to Hi3516D V300](https://device.harmonyos.com/en/docs/documentation/guide/ide-hi3516-upload-0000001052148681)/[Burning to Hi3518E V300](https://device.harmonyos.com/en/docs/documentation/guide/ide-hi3518-upload-0000001057313128#section93591711580).
Select the U-Boot files of corresponding development boards for burning by referring to [Burning to Hi3516D V300](https://device.harmonyos.com/en/docs/documentation/guide/ide-hi3516-upload-0000001052148681).
3. Log in to the serial port after the burning is complete.
......
......@@ -15,7 +15,7 @@ To accommodate different developer habits, OpenHarmony provides two modes for ge
- Installation package mode: Dependency download and installation as well as building operations are performed using commands. Burning and running are performed in DevEco Device Tool. OpenHarmony also provides the [Docker environment](../get-code/gettools-acquire.md), which can significantly simplify the environment configuration before compilation. You can build your source code in the Docker environment if you are more accustomed to using the installation package mode.
This document exemplifies how to use the installation package mode. For details about the IDE mode, see [Getting Started with Mini and Small Systems (IDE Mode)](../quick-start/quickstart-lite-ide-directory.md).
This document exemplifies how to use the installation package mode. For details about the IDE mode, see [Getting Started with Mini and Small Systems (IDE Mode)](../quick-start/quickstart-ide-lite-overview.md).
## Development Environment
......@@ -31,7 +31,7 @@ This document describes how to develop OpenHarmony in the Windows+Ubuntu environ
## Development Boards
In this document, two development board models are used as examples: Hi3861 and Hi3516D V300. For details about these development boards, see [Appendix](../quick-start/quickstart-lite-board-introduction.md). You can purchase the development board as required.
In this document, two development board models are used as examples: Hi3861 and Hi3516D V300. For details about these development boards, see [Appendix](../quick-start/quickstart-lite-introduction-hi3861.md). You can purchase the development board as required.
## Development Process
......
......@@ -12,7 +12,7 @@ To accommodate different developer habits, OpenHarmony provides two modes for ge
- Installation package mode: Dependency download and installation as well as building operations are performed using commands. Burning and running are performed in DevEco Device Tool.
OpenHarmony also provides the [Docker environment](../get-code/gettools-acquire.md), which can significantly simplify the environment configuration before compilation. You can build your source code in the Docker environment if you are more accustomed to using the installation package mode.
This document exemplifies how to use the installation package mode. For details about the IDE mode, see [Getting Started with Standard System (IDE Mode)](../quick-start/quickstart-standard-ide-directory.md).
This document exemplifies how to use the installation package mode. For details about the IDE mode, see [Getting Started with Standard System (IDE Mode)](../quick-start/quickstart-ide-standard-overview.md).
## Development Environment
......@@ -28,7 +28,7 @@ This document describes how to develop OpenHarmony in the Windows+Ubuntu environ
## Development Boards
In this document, two development board models are used as examples: Hi3516D V300 and RK3516. For details about these development boards, see [Appendix](../quick-start/quickstart-standard-board-introduction.md). You can purchase the development board as required.
In this document, two development board models are used as examples: Hi3516D V300 and RK3516. For details about these development boards, see [Appendix](../quick-start/quickstart-standard-board-introduction-hi3516.md). You can purchase the development board as required.
## Development Process
......
......@@ -8,7 +8,7 @@ The following exemplifies how to run the first program on the development board.
The complete code directory is as follows:
```
applications/sample/hello
│ │── BUILD.gn
......@@ -21,7 +21,7 @@ build
└── subsystem_config.json
productdefine/common
└── products
└── Hi3568DV300.json
└── Hi3516DV300.json
```
......@@ -34,7 +34,7 @@ Perform the steps below in the source code directory:
Create the **applications/sample/hello/src/helloworld.c** directory and file whose code is shown in the following example. You can customize the content to be printed. For example, you can change **World** to **OH**. Declare the string printing function **HelloPrint** in the **helloworld.h** file. You can use either C or C++ to develop a program.
```
#include <stdio.h>
#include "helloworld.h"
......@@ -55,7 +55,7 @@ Perform the steps below in the source code directory:
Add the header file **applications/sample/hello/include/helloworld.h**. The sample code is as follows:
```
#ifndef HELLOWORLD_H
#define HELLOWORLD_H
......@@ -78,7 +78,7 @@ Perform the steps below in the source code directory:
2. Create a build file.
1. Create the **applications/sample/hello/BUILD.gn** file. The file content is as follows:
```
import("//build/ohos.gni") # Import the build template.
ohos_executable("helloworld") {# Executable module.
......@@ -99,7 +99,7 @@ Perform the steps below in the source code directory:
}
```
2. Create the **applications/sample/hello/bundle.json** file and add the description of the **sample** component. The content is as follows:
```
{
"name": "@ohos/hello",
......@@ -141,7 +141,7 @@ Perform the steps below in the source code directory:
Add the configuration of the new subsystem to the **build/subsystem_config.json** file.
```
"sample": {
"path": "applications/sample/hello",
......@@ -153,7 +153,7 @@ Perform the steps below in the source code directory:
In the **productdefine/common/products/Hi3516DV300.json** file, add the **hello** part after the existing part.
```
"usb:usb_manager_native":{},
"applications:prebuilt_hap":{},
......
# HiChecker Development
## Overview
HiChecker is a framework provided by OpenHarmony for checking code errors and runtime results. It can be used for checking runtime errors during application and system development. This section applies only to the standard system.
## Development Guidelines
### Use Cases
HiChecker is provided for you to check issues that may be easily ignored during development of OpenHarmony applications (including system-built and third-party applications). Such issues include calling of time-consuming functions by key application threads, event distribution and execution timeout in application processes, and ability resource leakage in application processes. The issues are recorded in logs or lead to process crashes explicitly so that you can notice them and take correction measures.
### Available APIs
HiChecker provides the APIs listed in the following table.
**Table 1** HiChecker APIs
| **API**| **Description**|
| -------- | -------- |
| uint_64_t&nbsp;RULE_CAUTION_PRINT_LOG<br>=&nbsp;1&lt;&lt;63; | Defines an alarm rule, which is programmed to record a log when an alarm is generated.|
| uint_64_t&nbsp;RULE_CAUTION_TRIGGER_CRASH&nbsp;=&nbsp;1&lt;&lt;62; | Defines an alarm rule, which is programmed to force the application to exit when an alarm is generated.|
| uint_64_t&nbsp;RULE_THREAD_CHECK_SLOW_PROCESS&nbsp;=&nbsp;1; | Defines a check rule, which is programmed to check whether any time-consuming function is called.|
| uint_64_t&nbsp;RULE_CHECK_SLOW_EVENT&nbsp;=&nbsp;1&lt;&lt;32; | Defines a check rule, which is programmed to check whether the event distribution or processing time has exceeded the specified time threshold.|
| uint_64_t&nbsp;RULE_CHECK_ABILITY_CONNECTION_LEAK&nbsp;=&nbsp;1&lt;&lt;33; | Defines a check rule, which is programmed to check ability leakage.|
| AddRule(uint_64_t&nbsp;rule)&nbsp;:&nbsp;void | Adds one or more rules. HiChecker detects unexpected operations or gives feedback based on the added rules.|
| RemoveRule(uint_64_t&nbsp;rule)&nbsp;:&nbsp;void | Removes one or more rules. The removed rules will no longer take effect.|
| GetRule()&nbsp;:&nbsp;uint_64_t | Obtains a collection of thread, process, and alarm rules that have been added.|
| Contains(uint_64_t&nbsp;rule)&nbsp;:&nbsp;bool | Checks whether the collection of added rules contains a specific rule. If a thread-level rule is specified, the system only checks whether it is contained in the current thread.|
| NotifySlowProcess(std::string&nbsp;tag)&nbsp;:&nbsp;void | Notifies your application of a slow process so that your application avoids calling it directly in key threads.|
| NotifySlowEvent(std::string&nbsp;tag)&nbsp;:&nbsp;void | Notifies your application that event distribution or execution has timed out.|
| NotifyAbilityConnectionLeak(Caution&nbsp;caution)&nbsp;:&nbsp;void | Notifies your application that AbilityConnection leakage has occurred.|
| GetTriggerRule()&nbsp;:&nbsp;uint_64_t | Obtains the rule that triggers the current alarm.|
| GetCautionMsg()&nbsp;:&nbsp;std::string | Obtains the alarm message.|
| GetStackTrace()&nbsp;:&nbsp;std::string | Obtains the stack when an alarm is triggered.|
### Development Example
C++
1. Include the following HiChecker header file in the code file:
```
#include "hichecker.h"
```
For a non-DFX subsystem, add the **HiviewDFX** field.
```
using namespace OHOS::HiviewDFX;
```
Use related APIs through static calls.
```
HiChecker::AddRule(Rule::RULE_THREAD_CHECK_SLOW_PROCESS); // Add a rule.
HiChecker::AddRule(Rule::RULE_CHECK_SLOW_EVENT | Rule::RULE_CAUTION_PRINT_LOG); // Add multiple rules.
HiChecker::Contains(Rule::RULE_CAUTION_PRINT_LOG); // true
HiChecker::GetRule(); //RULE_THREAD_CHECK_SLOW_PROCESS | RULE_CHECK_SLOW_EVENT | RULE_CAUTION_PRINT_LOG
```
When a rule is triggered, an alarm is generated based on the rule, and a log is recorded by default.
- RULE_CAUTION_PRINT_LOG
The log prints information such as the rule, thread ID, thread name, and stack that triggers the alarm.
- RULE_CAUTION_TRIGGER_CRASH
The process exits directly, and the log prints the exit prompt and other auxiliary information.
Usage of the **Notify** APIs:
- NotifySlowProcess(std::string tag)
Notifies your application that a slow process has been called. The following is an example of the input arguments:
```
"threadId: xx,threadName:xx,actualTime:xx,delayTime:xx"
```
- NotifySlowEvent(std::string tag)
Notifies your application that event distribution or execution has timed out. The following is an example of the input arguments:
```
"threadId: xx,threadName:xx,eventName:xx,actualTime:xx,delayTime:xx"
```
- NotifyAbilityConnectionLeak(Caution caution)
Notifies your application that AbilityConnection leakage has occurred. The following example shows that a **Caution** instance is passed into this API.
```
Caution caution(Rule::RULE_CHECK_ABILITY_CONNECTION_LEAK , cautionMessage, stackTrace)
// cautionMessage is similar to other Notify APIs.
// stackTrace indicates the stack information when leakage occurs.
```
2. Add the subsystem dependency to the **BUILD.gn** file that has imported the HiChecker module.
```
include_dirs = [ "//base/hiviewdfx/interfaces/innerkits/libhichecker/include" ]
external_deps = [ "hichecker_native:libhichecker" ]
```
# HiDumper Development
## Overview
### Introduction
HiDumper is a tool provided by OpenHarmony for developers, testers, and IDE tool engineers to obtain system information necessary for analyzing and locating faults. This section applies only to the standard system.
### Source Code Directories
```
/base/hiviewdfx/hidumper
├── frameworks # Framework code
│ ├── native # Core function code
│ │ │── include # Header files
│ │ │── src # Source files
│ │ │── common # Common function code
│ │ │── executor # Process executor code
│ │ │── factory # Factory code
│ │ │── manager # Core manager code
│ │ │── util # Utility source code
│── sa_profile # HiDumper SA profile
│── services # HiDumper service code
│ │── native # C++ service code
│ │── zidl # Communication function
│ │ │── include # Header files of the communication function
│ │ │── src # Source code of the communication function
├── test # Test cases
│ ├── unittest # Unit test code
│ ├── moduletest # Module-level test code
```
## Usage
### Command-Line Options
**Table 1** HiDumper command-line options
| Option| Description|
| -------- | -------- |
| -h | Shows the help Information.|
| -t&nbsp;[timeout] | Specifies the timeout period, in seconds. The default value is **30**. Value **0** indicates no timeout limit.|
| -lc | Shows the system information cluster list.|
| -ls | Shows the system ability list.|
| -c | Exports system cluster information.|
| -c&nbsp;[base&nbsp;system] | Exports system cluster information based on **base** or **system** tags.|
| -s | Exports all system ability information.|
| -s&nbsp;[SA0&nbsp;SA1] | Exports ability information corresponding to SA0 and SA1.|
| -s&nbsp;[SA]&nbsp;-a&nbsp;['-h'] | Exports the system ability information **SA** using the **-h** parameter.|
| -e | Exports crash logs generated by the FaultLogger module.|
| --net | Exports network information.|
| --storage | Exports storage information.|
| -p | Exports the process list and all process information.|
| -p&nbsp;[pid] | Exports all information about a specified process.|
| --cpuusage&nbsp;[pid] | Exports the CPU usage information based on **pid**.|
| --cpufreq | Exports the actual CPU frequency.|
| --mem&nbsp;[pid] | Exports the memory usage information based on **pid**.|
| --zip | Compresses the exported information to a specified folder.|
### Development Example
HiDumper helps you export basic system information to locate and analyze faults. Complex parameters passed to sub-services and abilities must be enclosed in double quotation marks.
The procedure is as follows:
1. Access the device CLI, and run the **hidumper -h** command to obtain the help information, which includes basic information and function syntax.
```
hidumper -h
```
2. Run the **hidumper -lc** command to obtain the system information cluster list.
```
hidumper -lc
```
3. Run the **hidumper -c** command to obtain all information that is classified by **base** and **system**.
```
hidumper -c
```
4. Run the **hidumper -c [base | system]** to obtain the system cluster information that is classified by **base** or **system**.
```
hidumper -c base
hidumper -c system
```
5. Run the **hidumper -ls** command to obtain the system ability list.
```
hidumper -ls
```
6. Run the **hidumper -s** command to obtain all system ability information.
```
hidumper -s
```
7. Run the **hidumper -s 3301 -a "-h"** command to obtain the help information about the ability whose ID is **3301**.
```
hidumper -s 3301 -a "-h"
```
8. Run the **hidumper -s 3008** command to obtain all information about the ability whose ID is **3008**.
```
hidumper -s 3008
```
9. Run the **hidumper -e** command to obtain the crash information generated by the FaultLogger module.
```
hidumper -e
```
10. Run the **hidumper --net** command to obtain network information.
```
hidumper --net
```
11. Run the **hidumper --storage** command to obtain storage information.
```
hidumper --storage
```
12. Run the **hidumper -p** command to obtain process information, including the list and information of processes and threads.
```
hidumper -p
```
13. Run the **hidumper -p 1024** command to obtain information about the process whose PID is **1024**.
```
hidumper -p 1024
```
14. Run the **hidumper --cpuusage [pid]** command to obtain the CPU usage information of the process whose PID has been specified.
```
hidumper --cpuusage
hidumper --cpuusage 1024
```
15. Run the **hidumper --cpufreq** command to obtain the actual operating frequency of each CPU core.
```
hidumper --cpufreq
```
16. Run the **hidumper --mem [pid]** command to obtain all memory usage information of the process whose PID has been specified.
```
hidumper --mem [pid]
```
17. Run the **hidumper --zip** command to compress data to the **/data/dumper** directory.
```
hidumper --zip
```
18. Run the **hidumper -t timeout** command to set the timeout period, in seconds. The default value is **30**. Value **0** indicates no timeout limit.
```
hidumper -t [timeout]
```
......@@ -4,11 +4,14 @@
The DFX subsystem provides the following functions:
- HiLog: implements the logging function. It is applicable to Mini-System Devices \(reference memory ≥ 128 KiB\), Small-System Devices \(reference memory ≥ 1 MiB\), and Standard-System Devices \(reference memory ≥ 128 MB\).
- HiLog: implements the logging function. It is applicable to mini-system devices \(reference memory ≥ 128 KiB\), small-system devices \(reference memory ≥ 1 MiB\), and standard-system devices \(reference memory ≥ 128 MB\).
- HiTrace: implements distributed call chain tracing. It is applicable to Standard-System Devices \(reference memory ≥ 128 MB\).
- HiCollie: implements thread suspension detection. It is applicable to Standard-System Devices \(reference memory ≥ 128 MB\).
- HiSysEvent: implements system event logging. It is applicable to Standard-System Devices \(reference memory ≥ 128 MB\).
- HiTrace: implements distributed call chain tracing. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- HiCollie: implements thread suspension detection. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- HiSysEvent: implements system event logging. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- HiChecker: implements defect scanning. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- HiDumper: exports system information. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
- FaultLogger: implements crash detection. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\).
## Basic Concepts<a name="section5635178134811"></a>
......@@ -31,4 +34,3 @@ Event logging means to collect and log events reported during system running. Th
**System event**
A system event is an indication of the system status at a given time point during system running. You can use these events to analyze the status change of the system.
# OpenHarmony Device Development Documentation
- [Device Development Guide](device-dev-guide.md)
- Quick Start
- Getting Started
- Getting Started with Mini and Small Systems (IDE Mode, Recommended)
- [Mini and Small System Overview](quick-start/quickstart-ide-lite-overview.md)
- Environment Preparation
......@@ -20,8 +21,9 @@
- [Burning](quick-start/quickstart-ide-lite-steps-hi3516-burn.md)
- [Running](quick-start/quickstart-ide-lite-steps-hi3516-running.md)
- Appendix
- [Introduction to the Hi3861 Development Board](quick-start/quickstart-ide-lite-introduction-hi3861.md)
- [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-lite-introduction-hi3516.md)
- Introduction to Development Boards
- [Introduction to the Hi3861 Development Board](quick-start/quickstart-ide-lite-introduction-hi3861.md)
- [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-lite-introduction-hi3516.md)
- Getting Started with Mini and Small Systems (Installation Package Mode)
- [Mini and Small System Overview](quick-start/quickstart-lite-overview.md)
- [Environment Preparation](quick-start/quickstart-lite-env-setup.md)
......@@ -67,8 +69,9 @@
- [Burning](quick-start/quickstart-ide-standard-running-rk3568-burning.md)
- [Running](quick-start/quickstart-ide-standard-running-rk3568-running.md)
- Appendix
- [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-standard-board-introduction-hi3516.md)
- [Introduction to the RK3568 Development Board](quick-start/quickstart-ide-standard-board-introduction-rk3568.md)
- Introduction to Development Boards
- [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-standard-board-introduction-hi3516.md)
- [Introduction to the RK3568 Development Board](quick-start/quickstart-ide-standard-board-introduction-rk3568.md)
- Getting Started with Standard System (Installation Package Mode)
- [Standard System Overview](quick-start/quickstart-standard-overview.md)
- [Setting Up Environments for Standard System](quick-start/quickstart-standard-env-setup.md)
......@@ -92,14 +95,14 @@
- [Introduction to the Hi3516 Development Board](quick-start/quickstart-standard-board-introduction-hi3516.md)
- [Introduction to the RK3568 Development Board](quick-start/quickstart-standard-board-introduction-rk3568.md)
- [Reference](quick-start/quickstart-standard-reference.md)
- [Obtaining Source Code](get-code/sourcecode-acquire.md)
- [Obtaining Source Code](get-code/sourcecode-acquire.md)
- Compatibility and Security
- [Privacy Protection](security/security-privacy-protection.md)
- [Security Guidelines](security/security-guidelines-overall.md)
- Porting
- Mini System SoC Porting Guide
- Porting Preparations
- [Before You Start](porting/oem_transplant_chip_prepare_knows.md)
- [Before You Start](porting/porting-chip-prepare-knows.md)
- [Building Adaptation Process](porting/porting-chip-prepare-process.md)
- Kernel Porting
- [Overview](porting/porting-chip-kernel-overview.md)
......@@ -133,8 +136,8 @@
- [Porting a Library Built Using CMake](porting/porting-thirdparty-cmake.md)
- [Porting a Library Built Using Makefile](porting/porting-thirdparty-makefile.md)
- Mini System SoC Porting Cases
- [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting/porting-bes2600w-on-minisystem-display-demo.md)
- [Combo Solution – ASR Chip Porting Case](porting/porting-asr582x-combo-demo.md)
- [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting-bes2600w-on-minisystem-display-demo.md)
- [Combo Solution – ASR Chip Porting Case](porting-asr582x-combo-demo.md)
- Subsystem Development
- Kernel
- Kernel for Mini Systems
......@@ -170,8 +173,7 @@
- [LMS](kernel/kernel-mini-memory-lms.md)
- Appendix
- [Kernel Coding Specification](kernel/kernel-mini-appx-code.md)
- Basic Data Structure
- [Doubly Linked List](kernel/kernel-mini-appx-data-list.md)
- [Doubly Linked List](kernel/kernel-mini-appx-data-list.md)
- Standard Libraries
- [CMSIS Support](kernel/kernel-mini-appx-lib-cmsis.md)
- [POSIX Support](kernel/kernel-mini-appx-lib-posix.md)
......@@ -245,8 +247,6 @@
- [uname](kernel/kernel-small-debug-shell-cmd-uname.md)
- [vmm](kernel/kernel-small-debug-shell-cmd-vmm.md)
- [watch](kernel/kernel-small-debug-shell-cmd-watch.md)
- [reboot](kernel/kernel-small-debug-shell-cmd-reboot.md)
- [top](kernel/kernel-small-debug-shell-cmd-top.md)
- File Commands
- [cat](kernel/kernel-small-debug-shell-file-cat.md)
- [cd](kernel/kernel-small-debug-shell-file-cd.md)
......@@ -269,8 +269,6 @@
- [touch](kernel/kernel-small-debug-shell-file-touch.md)
- [writeproc](kernel/kernel-small-debug-shell-file-write.md)
- [umount](kernel/kernel-small-debug-shell-file-umount.md)
- [du](kernel/kernel-small-debug-shell-file-du.md)
- [mv](kernel/kernel-small-debug-shell-file-mv.md)
- Network Commands
- [arp](kernel/kernel-small-debug-shell-net-arp.md)
- [dhclient](kernel/kernel-small-debug-shell-net-dhclient.md)
......@@ -285,8 +283,8 @@
- [Magic Key](kernel/kernel-small-debug-shell-magickey.md)
- [User-Space Exception Information](kernel/kernel-small-debug-shell-error.md)
- [Trace](kernel/kernel-small-debug-trace.md)
- [perf](kernel/kernel-mini-memory-perf.md)
- [LMS](kernel/kernel-small-memory-lms.md)
- [perf](kernel/kernel-mini-memory-perf)
- [LMS](kernel/kernel-small-memory-lms)
- [CPUP](kernel/kernel-small-debug-process-cpu.md)
- Memory Debugging
- [Memory Information Statistics](kernel/kernel-small-debug-memory-info.md)
......@@ -328,31 +326,39 @@
- [HDF Development Example](driver/driver-hdf-sample.md)
- Platform Driver Development
- [ADC](driver/driver-platform-adc-develop.md)
- [DAC](driver/driver-platform-dac-develop.md)
- [GPIO](driver/driver-platform-gpio-develop.md)
- [HDMI](driver/driver-platform-hdmi-develop.md)
- [I2C](driver/driver-platform-i2c-develop.md)
- [I3C](driver/driver-platform-i3c-develop.md)
- [MIPI CSI](driver/driver-platform-mipicsi-develop.md)
- [MIPI DSI](driver/driver-platform-mipidsi-develop.md)
- [MMC](driver/driver-platform-mmc-develop.md)
- [PIN](driver/driver-platform-pin-develop.md)
- [PWM](driver/driver-platform-pwm-develop.md)
- [Regulator](driver/driver-platform-regulator-develop.md)
- [RTC](driver/driver-platform-rtc-develop.md)
- [SDIO](driver/driver-platform-sdio-develop.md)
- [SPI](driver/driver-platform-spi-develop.md)
- [UART](driver/driver-platform-uart-develop.md)
- [Watchdog](driver/driver-platform-watchdog-develop.md)
- [WatchDog](driver/driver-platform-watchdog-develop.md)
- Platform Driver Usage
- [ADC](driver/driver-platform-adc-des.md)
- [DAC](driver/driver-platform-dac-des.md)
- [GPIO](driver/driver-platform-gpio-des.md)
- [HDMI](driver/driver-platform-hdmi-des.md)
- [I2C](driver/driver-platform-i2c-des.md)
- [I3C](driver/driver-platform-i3c-des.md)
- [MIPI CSI](driver/driver-platform-mipicsi-des.md)
- [MIPI DSI](driver/driver-platform-mipidsi-des.md)
- [PIN](driver/driver-platform-pin-des.md)
- [PWM](driver/driver-platform-pwm-des.md)
- [Regulator](driver/driver-platform-regulator-des.md)
- [RTC](driver/driver-platform-rtc-des.md)
- [SDIO](driver/driver-platform-sdio-des.md)
- [SPI](driver/driver-platform-spi-des.md)
- [UART](driver/driver-platform-uart-des.md)
- [Watchdog](driver/driver-platform-watchdog-des.md)
- [WatchDog](driver/driver-platform-watchdog-des.md)
- Peripheral Driver Usage
- [LCD](driver/driver-peripherals-lcd-des.md)
- [Touchscreen](driver/driver-peripherals-touch-des.md)
......@@ -361,6 +367,8 @@
- [Audio](driver/driver-peripherals-audio-des.md)
- [USB](driver/driver-peripherals-usb-des.md)
- [Camera](driver/driver-peripherals-camera-des.md)
- [Vibrator](driver/driver-peripherals-vibrator-des.md)
- [Light](driver/driver-peripherals-light-des.md)
- Compilation and Building
- [Building Guidelines for Mini and Small Systems](subsystems/subsys-build-mini-lite.md)
- [Building Guidelines for Standard Systems](subsystems/subsys-build-standard-large.md)
......@@ -379,7 +387,7 @@
- [Development Guidelines on Photographing](subsystems/subsys-multimedia-camera-photo-guide.md)
- [Development Guidelines on Video Recording](subsystems/subsys-multimedia-camera-record-guide.md)
- [Development Guidelines on Previewing](subsystems/subsys-multimedia-camera-preview-guide.md)
- Audio/Video
- Audio and Video
- [Overview](subsystems/subsys-multimedia-video-overview.md)
- [Development Guidelines on Media Playback](subsystems/subsys-multimedia-video-play-guide.md)
- [Development Guidelines on Media Recording](subsystems/subsys-multimedia-video-record-guide.md)
......@@ -422,16 +430,15 @@
- [Setting Up a Development Environment](subsystems/subsys-application-framework-envbuild.md)
- [Development Guidelines](subsystems/subsys-application-framework-guide.md)
- [Development Example](subsystems/subsys-application-framework-demo.md)
- [OTA Upgrade](subsystems/subsys-ota-guide.md)
- Telephony Service
- [Telephony Service](subsystems/telephony-service.md)
- [Development Guidelines](subsystems/development-guidelines.md)
- [OTA Update](subsystems/subsys-ota-guide.md)
- Telephony
- [Telephony Overview](subsystems/subsys-tel-overview.md)
- [Telephony Development](subsystems/subsys-tel-guide.md)
- Security
- [Overview](subsystems/subsys-security-overview.md)
- [Development Guidelines on Application Signature Verification](subsystems/subsys-security-sigverify.md)
- [Development Guidelines on Application Permission Management](subsystems/subsys-security-rightmanagement.md)
- [Development Guidelines on IPC Authentication](subsystems/subsys-security-communicationverify.md)
- [Development on Device Security Level Management](subsystems/subsys-security-devicesecuritylevel.md)
- Startup
- [Startup](subsystems/subsys-boot-overview.md)
- [init Module](subsystems/subsys-boot-init.md)
......@@ -470,7 +477,7 @@
- [Photographing](guide/device-iotcamera-control-demo-photodevguide.md)
- [Video Recording](guide/device-iotcamera-control-demo-videodevguide.md)
- [Use Case](guide/device-iotcamera-control-example.md)
- Cameras with a Screen
- Cameras with a Screen)
- Screen and Camera Control
- [Overview](guide/device-camera-control-overview.md)
- Development Guidelines
......@@ -493,10 +500,10 @@
- [Development Example for Peripheral Drivers](guide/device-outerdriver-demo.md)
- Debugging
- [Test Subsystem](subsystems/subsys-testguide-test.md)
- [R&D Tools](subsystems/subsys-toolchain.md)
- Debugging Tools
- [bytrace Usage Guidelines](subsystems/subsys-toolchain-bytrace-guide.md)
- [hdc_std Usage Guidelines](subsystems/subsys-toolchain-hdc-guide.md)
- [XTS](subsystems/subsys-xts-guide.md)
- [XTS Certification](subsystems/subsys-xts-guide.md)
- Tools
- [Docker Environment](get-code/gettools-acquire.md)
- [IDE](get-code/gettools-ide.md)
......
# 应用上下文使用指导
## Context概述
​ context是应用中对象的上下文,提供获取应用程序环境信息的能力。
## Context整体结构介绍
​ OpenHarmony的应用框架分为FA模型和Stage两种模型。对应存在两套Context机制适配两种应用框架模型:
**application/BaseContext** 属于一个通用的Context基类,既不属于FA模型也不属于Stage模型,里面只有一个属性stageMode,用来区分开发模型是FA还是Stage。
**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详细介绍)种进行说明。
![contextIntroduction](figures/contextIntroduction.png)
## FA模型的Context详细介绍
​ 只有app/Context中的方法属于FA模型对应的Context。
​ FA模型只有一个Context定义。Context中所有的功能都是通过方法来提供的,它提供了一些featureAbility中不存在的方法,相当于featureAbility的一个扩展和补全。
​ d.ts文件如下:
​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/app/context.d.ts
​ 应用的使用方式:
```javascript
// 1.引入featureAbility
import featureAbility from '@ohos.ability.featureAbility'
export default {
onCreate() {
console.log('Application onCreate')
// 2.获取Context
let context = featureAbility.getContext();
// 3.调用对应的方法
context.setShowOnLockScreen(false, (data) => {
console.log("data: " + JSON.stringify(data));
});
},
onActive() {
console.log('Application onActive')
},
onDestroy() {
console.log('Application onDestroy')
},
}
```
## Stage模型和Context详细介绍
​ Stage模型有6大Context:
### application/Context
**概述**
​ application/Context类型的Context是基类Context,里面提供了应用的一些基础信息:resourceManager、applicationInfo、cacheDir等,还有应用的一些基本方法:createBundleContext、switchArea等。应用级别的Context也是application/Context这种类型。
**获取方法**
​ 需要在AbilityStage、Ability、Extension等组件中通过context.getApplicationContext()拿到。
**示例**
```javascript
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('MainAbility onCreate is called' + want + launchParam);
// 获取ApplicationContext
let appContext = this.context.getApplicationContext();
// 获取路径
console.log('filesDir is ' + appContext.filesDir);
}
onDestroy() {
console.log('MainAbility onDestroy is called');
}
}
```
**d.ts声明**
​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/Context.d.ts
### application/AbilityStageContext
**概述**
​ application/AbilityStageContext是Hap包级别的Context。和基类Context相比,Hap包级别的Context中多了HapModuleInfo和Configuration两个信息。
**获取方法**
​ 可以直接在AbilityStage中通过context属性拿到。
**示例**
```javascript
export default class MyAbilityStage extends AbilityStage {
onCreate() {
// 属性context就是AbilityStageContext类型的
console.log('HapModuleInfo is ' + context.currentHapModuleInfo);
}
}
```
**d.ts声明**
​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AbilityStageContext.d.ts
### application/AbilityContext
**概述**
​ Stage模型下,每个Ability中都包含了一个Context属性。
​ Ability功能主要是处理生命周期,其余操作Ability的方法(如startAbility、connectAbility等)都是在AbilityContext中实现的。
**获取方法**
​ 在Ability中通过context属性拿到。
**示例**
```javascript
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('MainAbility onCreate is called' + want + launchParam);
var want = {
"bundleName": "com.example.MyApplication",
"abilityName": "ServiceExtAbility",
}
// 1.这里的Context就是AbilityContext
let contxt = this.context;
// 2.startAbility
contxt.startAbility(want).then((data) => {
console.info("startAbility success:" + JSON.stringify(data));
}).catch((error) => {
console.error("startAbility failed:" + JSON.stringify(error));
});
}
onDestroy() {
console.log("MainAbility on Destroy is called");
}
}
```
**d.ts声明**
​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AbilityContext.d.ts
### application/ExtensionContext
**概述**
​ 和FA模型不同的是,Stage模型把Service从Ability中剥离出来,单独定义了一组通用扩展类Extension用来处理等同的功能。Extension是一个基类,不承担具体业务功能。业务方根据自己的需要去扩展对应的Extension,例如:ServiceAbility扩展为了ServiceExtensionAbility,卡片扩展为了FormExtension。
​ 因此新增了一种和Extension匹配的ExtensionContext。ExtensionContext中包含HapModuleInfo和Configuration两个属性。
**获取方法**
​ 不会单独使用。
**d.ts声明**
​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ExtensionContext.d.ts
### application/ServiceExtensionContext
**概述**
​ ServiceExtensionAbility类似于FA模型的ServiceAbility,里面只有生命周期回调相关的处理。
​ 操作ServiceExtensionAbility的方法移动到了ServiceExtensionContext中(如startAbility、connectAbility等)。
**获取方法**
​ ServiceExtensionAbility中通过context属性获取。
**示例**
```javascript
export default class ServiceExtAbility extends ServiceExtensionAbility {
onCreate(want) {
console.info("ServiceAbility onCreate**");
// 1.这里的Context就是ServiceExtensionContext
let contxt = this.context;
}
onRequest(want, startId) {
console.info("ServiceAbility onRequest**");
}
onConnect(want) {
console.info("ServiceAbility onConnect**");
return new StubTest("test");
}
onDisconnect(want) {
console.info("ServiceAbility onDisconnect**");
}
onDestroy() {
console.info("ServiceAbility onDestroy**");
}
}
```
**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**
**结论**
​ FA模型可以通过该方式去获取;Stage模型不可通过该方式去获取,要通过对应组件的属性去获取。
**原因**
​ 应用框架在API8上推出了新的应用模型(Stage模型)。在老的模型(FA模型)下,每个Ability实例有一个js虚拟机实例,所以可以从js引擎的global对象上,获取到一个全局的Ability实例,但是在新的模型(Stage模型)下,整个应用进程共用一个js虚拟机实例,其中可以运行多个Ability实例,这样就不存在一个全局的Ability实例。如果开发者在新的模型(Stage模型)下,调用的API实现仍然走到了获取全局Ability实例的方法,就可能会发生错误或者崩溃。
\ No newline at end of file
......@@ -231,7 +231,7 @@ Form需要在应用配置文件config.json中进行配置。
}
```
具体的持久化方法可以参考[轻量级数据存储开发指导](../database/database-preference-guidelines.md)
具体的持久化方法可以参考[轻量级数据存储开发指导](../database/database-storage-guidelines.md)
需要注意的是,卡片使用方在请求卡片时传递给提供方应用的Want数据中存在临时标记字段,表示此次请求的卡片是否为临时卡片:
......
......@@ -24,16 +24,16 @@
```javascript
export default {
onStart(want) {
onStart() {
console.log('ServiceAbility onStart');
},
onCommand(want, restart, startId) {
onCommand(want, startId) {
console.log('ServiceAbility onCommand');
},
onConnect(want) {
console.log('ServiceAbility OnConnect');
},
onDisconnect() {
onDisconnect(want) {
console.log('ServiceAbility OnDisConnect');
},
onStop() {
......@@ -174,7 +174,7 @@ import rpc from "@ohos.rpc";
let mMyStub;
export default {
onStart(want) {
onStart() {
class MyStub extends rpc.RemoteObject{
constructor(des) {
if (typeof des === 'string') {
......@@ -182,7 +182,7 @@ export default {
}
return null;
}
onRemoteRequest(code, message, reply, option) {
onRemoteRequest(code, data, reply, option) {
console.log("ServiceAbility onRemoteRequest called");
if (code === 1) {
let op1 = data.readInt();
......@@ -197,14 +197,14 @@ export default {
}
mMyStub = new MyStub("ServiceAbility-test");
},
onCommand(want, restart, startId) {
onCommand(want, startId) {
console.log('ServiceAbility onCommand');
},
onConnect(want) {
console.log('ServiceAbility OnConnect');
return mMyStub;
},
onDisconnect() {
onDisconnect(want) {
console.log('ServiceAbility OnDisConnect');
},
onStop() {
......@@ -225,12 +225,12 @@ export default {
```ts
let mRemote;
function onConnectCallback(element, remote){
console.log('onConnectLocalService onConnectDone element: ' + element);
console.log('onConnectLocalService onConnectDone remote: ' + remote);
console.log('onConnectRemoteService onConnectDone element: ' + element);
console.log('onConnectRemotelService onConnectDone remote: ' + remote);
mRemote = remote;
if (mRemote == null) {
prompt.showToast({
message: "onConnectLocalService not connected yet"
message: "onConnectRemoteService not connected yet"
});
return;
}
......@@ -243,7 +243,7 @@ function onConnectCallback(element, remote){
console.log('sendRequest success');
let msg = reply.readInt();
prompt.showToast({
message: "onConnectLocalService connect result: " + msg,
message: "onConnectRemoteService connect result: " + msg,
duration: 3000
});
}).catch((e) => {
......
......@@ -244,7 +244,7 @@ Form需要在应用配置文件module.json中进行配置。
}
```
具体的持久化方法可以参考[轻量级数据存储开发指导](../database/database-preference-guidelines.md)。
具体的持久化方法可以参考[轻量级数据存储开发指导](../database/database-storage-guidelines.md)。
需要注意的是,卡片使用方在请求卡片时传递给提供方应用的Want数据中存在临时标记字段,表示此次请求的卡片是否为临时卡片:
......
......@@ -159,13 +159,13 @@
- [自定义组件生命周期回调函数](ui/ts-custom-component-lifecycle-callbacks.md)
- [组件创建和重新初始化示例](ui/ts-component-creation-re-initialization.md)
- [语法糖](ui/ts-syntactic-sugar.md)
- 常见组件开发指导
- [Button开发指导](ui/ui-ts-basic-components-button.md)
- [Web开发指导](ui/ui-ts-components-web.md)
- 常见布局开发指导
- [弹性布局](ui/ui-ts-layout-flex.md)
- [栅格布局](ui/ui-ts-layout-grid-container.md)
- [媒体查询](ui/ui-ts-layout-mediaquery.md)
- 常见组件开发指导
- [Button开发指导](ui/ui-ts-basic-components-button.md)
- [Web开发指导](ui/ui-ts-components-web.md)
- 常见布局开发指导
- [弹性布局](ui/ui-ts-layout-flex.md)
- [栅格布局](ui/ui-ts-layout-grid-container.md)
- [媒体查询](ui/ui-ts-layout-mediaquery.md)
- 体验声明式UI
- [创建声明式UI工程](ui/ui-ts-creating-project.md)
- [初识Component](ui/ui-ts-components.md)
......@@ -198,6 +198,7 @@
- [音频采集开发指导](media/audio-capturer.md)
- 视频
- [视频播放开发指导](media/video-playback.md)
- [视频录制开发指导](media/video-recorder.md)
- 图片
- [图片开发指导](media/image.md)
- 安全
......
......@@ -9,5 +9,7 @@
- 视频
- [视频播放开发指导](video-playback.md)
- [视频录制开发指导](video-recorder.md)
- 图片
- [图片开发指导](image.md)
# 视频录制开发指导
## 场景介绍
视频录制的主要工作是捕获音视频信号,完成音视频编码并保存到文件中,帮助开发者轻松实现音视频录制功能。它允许调用者指定录制的编码格式、封装格式、文件路径等参数。
**图1** 视频录制状态机
![zh-ch_image_video_recorder_state_machine](figures/zh-ch_image_video_recorder_state_machine.png)
**图2** 视频录制零层图
![zh-ch_image_video_recorder_zero](figures/zh-ch_image_video_recorder_zero.png)
## 开发步骤
详细API含义可参考:[媒体服务API文档VideoRecorder](../reference/apis/js-apis-media.md)
### 全流程场景
包含流程:创建实例,设置录制参数,录制视频,暂停录制,恢复录制,停止录制,释放资源等流程。
```js
import media from '@ohos.multimedia.media'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
export class VideoRecorderDemo {
private testFdNumber; // 用于保存fd地址
// pathName是传入的录制文件名,例如:01.mp4,生成后的文件地址:/storage/media/100/local/files/Video/01.mp4
// 使用mediaLibrary需要添加以下权限, ohos.permission.MEDIA_LOCATION、ohos.permission.WRITE_MEDIA、ohos.permission.READ_MEDIA
async getFd(pathName) {
let displayName = pathName;
const mediaTest = mediaLibrary.getMediaLibrary();
let fileKeyObj = mediaLibrary.FileKey;
let mediaType = mediaLibrary.MediaType.VIDEO;
let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO);
let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath);
if (dataUri != undefined) {
let args = dataUri.id.toString();
let fetchOp = {
selections : fileKeyObj.ID + "=?",
selectionArgs : [args],
}
let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
let fileAsset = await fetchFileResult.getAllObject();
let fdNumber = await fileAsset[0].open('Rw');
this.testFdNumber = "fd://" + fdNumber.toString();
}
}
// 当发生错误上上报的错误回调接口
failureCallback(error) {
console.info('error happened, error name is ' + error.name);
console.info('error happened, error code is ' + error.code);
console.info('error happened, error message is ' + error.message);
}
// 当发生异常时,系统调用的错误回调接口
catchCallback(error) {
console.info('catch error happened, error name is ' + error.name);
console.info('catch error happened, error code is ' + error.code);
console.info('catch error happened, error message is ' + error.message);
}
async videoRecorderDemo() {
let videoRecorder = null; // videoRecorder空对象在createVideoRecorder成功后赋值
let surfaceID = null; // 用于保存getInputSurface返回的surfaceID
// 获取需要录制的视频的fd地址
await this.getFd('01.mp4');
// 录制相关参数配置
let videoProfile = {
audioBitrate : 48000,
audioChannels : 2,
audioCodec : 'audio/mp4a-latm',
audioSampleRate : 48000,
fileFormat : 'mp4',
videoBitrate : 48000,
videoCodec : 'video/mp4v-es',
videoFrameWidth : 640,
videoFrameHeight : 480,
videoFrameRate : 30
}
let videoConfig = {
audioSourceType : 1,
videoSourceType : 0,
profile : videoProfile,
url : this.testFdNumber, // testFdNumber由getFd生成
orientationHint : 0,
location : { latitude : 30, longitude : 130 },
}
// 创建videoRecorder对象
await media.createVideoRecorder().then((recorder) => {
console.info('case createVideoRecorder called');
if (typeof (recorder) != 'undefined') {
videoRecorder = recorder;
console.info('createVideoRecorder success');
} else {
console.info('createVideoRecorder failed');
}
}, this.failureCallback).catch(this.catchCallback);
// 调用prepare完成视频录制前的准备工作
await videoRecorder.prepare(videoConfig).then(() => {
console.info('prepare success');
}, this.failureCallback).catch(this.catchCallback);
// 获取surfaceID并保存下来传递给camera相关接口
await videoRecorder.getInputSurface().then((surface) => {
console.info('getInputSurface success');
surfaceID = surface;
}, this.failureCallback).catch(this.catchCallback);
// 视频录制依赖相机相关接口,以下需要先调用相机起流接口后才能继续执行,具体的相机接口调用请参考sample用例
// 视频录制启动接口
await videoRecorder.start().then(() => {
console.info('start success');
}, this.failureCallback).catch(this.catchCallback);
// 调用pause接口时需要暂停camera出流
await videoRecorder.pause().then(() => {
console.info('pause success');
}, this.failureCallback).catch(this.catchCallback);
// 调用resume接口时需要恢复camera出流
await videoRecorder.resume().then(() => {
console.info('resume success');
}, this.failureCallback).catch(this.catchCallback);
// 停止camera出流后,停止视频录制
await videoRecorder.stop().then(() => {
console.info('stop success');
}, this.failureCallback).catch(this.catchCallback);
// 重置录制相关配置
await videoRecorder.reset().then(() => {
console.info('reset success');
}, this.failureCallback).catch(this.catchCallback);
// 释放视频录制相关资源并释放camera对象相关资源
await videoRecorder.release().then(() => {
console.info('release success');
}, this.failureCallback).catch(this.catchCallback);
// 相关对象置null
videoRecorder = undefined;
surfaceID = undefined;
}
}
```
# Context
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
提供开发者运行代码的上下文环境,包括应用信息、ResourceManager等信息。
## 使用说明
通过AbilityContext等继承实现。
## 属性
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| resourceManager | ResourceManager | 是 | 否 | ResourceManager对象。 |
| applicationInfo | ApplicationInfo | 是 | 否 | 当前应用信息。 |
| cacheDir | string | 是 | 否 | 应用在内部存储上的缓存路径。 |
| tempDir | string | 是 | 否 | 应用的临时文件路径。 |
| filesDir | string | 是 | 否 | 应用在内部存储上的文件路径。 |
| databaseDir | string | 是 | 否 | 获取本地数据存储路径。 |
| storageDir | string | 是 | 否 | 获取轻量级数据存储路径。 |
| bundleCodeDir | string | 是 | 否 | 应用安装路径。 |
| distributedFilesDir | string | 是 | 否 | 应用的分布式文件路径。 |
| eventHub | [EventHub](js-apis-eventhub.md) | 是 | 否 | 事件中心信息。|
## Context.createBundleContext
createBundleContext(bundleName: string): Context;
创建指定应用上下文。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| bundleName | string | 是 | 应用bundle名。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Context | 对应创建应用的上下文context。 |
**示例:**
```js
let test = "com.example.test";
let context = this.context.createBundleContext(test);
```
## Context.getApplicationContext
getApplicationContext(): Context;
获取当前context。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Context | 当前Context&nbsp;信息。 |
**示例:**
```js
// 必选项。
let context = this.context.getApplicationContext();
```
......@@ -39,7 +39,7 @@ convert(xml: string, options?: ConvertOptions) : Object
- 示例:
```
```js
let xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......
# FormExtensionContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
FormExtension的上下文环境,提供FormExtension具有的能力和接口,继承自ExtensionContext。
## FormExtensionContext.updateForm
updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void
主动更新卡片。
**系统能力**:SystemCapability.Ability.Form
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| formId | string | 是 | 请求更新的卡片ID。 |
| formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 卡片新的数据。 |
| callback | AsyncCallback\<void> | 是 | 回调函数,返回接口调用是否成功的结果。 |
**示例:**
```js
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2, (data)=>{
console.log('FormExtension context updateForm, data:' + data);
});
```
## FormExtensionContext.updateForm
updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\<void>
更新卡片。
**系统能力**:SystemCapability.Ability.Form
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ------------------------------------------------------------ | ---- | ------------------ |
| formId | string | 是 | 请求更新的卡片ID。 |
| formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 卡片新的数据。 |
**返回值:**
| 类型 | 说明 |
| -------------- | --------------------------------- |
| Promise\<void> | 返回一个Promise,包含接口的结果。 |
**示例:**
```
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2)
.then((data)=>{
console.log('FormExtension context updateForm, data:' + data);
}).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);});
```
\ No newline at end of file
......@@ -9,7 +9,7 @@
## 导入模块
```
```typescript
import settings from '@ohos.settings';
```
......@@ -34,7 +34,7 @@ getUriSync(name: string): string
| string | 数据项的URI。 |
- 示例:
```
```typescript
// 获取数据项的URI
let urivar = settings.getUriSync('settings.screen.brightness');
```
......@@ -61,7 +61,7 @@ getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: strin
| string | 返回数据项的值。 |
- 示例:
```
```typescript
import featureAbility from '@ohos.featureAbility';
//获取数据项亮度的值(该数据项在数据库中已存在)
......@@ -96,7 +96,7 @@ setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string):
| boolean | 返回设置数据项的值是否成功的结果。true表示设置成功,false则表示设置失败。 |
- 示例:
```
```typescript
import featureAbility from '@ohos.featureAbility';
//更新数据项亮度的值(该数据项在数据库中已存在,故setValueSync方法将更新该数据项的值)
......
......@@ -46,11 +46,11 @@ constructor是URI的构造函数。
**示例:**
```
```js
var mm = 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment';
new uri.URI(mm); // Output 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment';
```
```
```js
new uri.URI('http://username:password@host:8080'); // Output 'http://username:password@host:8080';
```
......@@ -69,7 +69,7 @@ toString(): string
**示例:**
```
```js
const url = new uri.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toString()
```
......@@ -95,7 +95,7 @@ equals(other: URI): boolean
**示例:**
```
```js
const uriInstance = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
const uriInstance1 = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da#fragment');
uriInstance.equals(uriInstance1);
......@@ -115,7 +115,7 @@ checkIsAbsolute(): boolean
**示例:**
```
```js
const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080?query=pppppp');
uriInstance.checkIsAbsolute();
```
......@@ -134,7 +134,7 @@ normalize(): URI
| URI | 返回一个path被规范化后的URI对象。 |
**示例:**
```
```js
const uriInstance = new uri.URI('http://username:password@www.qwer.com:8080/path/path1/../path2/./path3?query=pppppp');
let uriInstance1 = uriInstance.normalize();
uriInstance1.path;
......
# WebGL
- [概述](webgl-overview.md)
- [WebGL开发概述](webgl-overview.md)
- [WebGL开发指导](webgl-guidelines.md)
此差异已折叠。
......@@ -12,7 +12,7 @@ OpenHarmony轻量和小型系统适用于内存较小的IOT设备(参考内存
- 安装包方式:通过命令行进行编译依赖工具的下载安装,编译操作也通过命令实现。烧录、运行等操作使用IDE。
OpenHarmony还为开发者提供了[Docker环境](../get-code/gettools-acquire.md),在很大程度上简化了编译前的环境配置,习惯使用安装包方式的开发者也可以选择Docker环境进行编译 。
本文采用DevEco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[轻量和小型系统快速入门(安装包方式)](../quick-start/quickstart-lite-package-directory.md)
本文采用DevEco Device Tool进行一站式开发介绍,习惯使用命令行的开发者可参考[轻量和小型系统快速入门(安装包方式)](../quick-start/quickstart-lite-overview.md)
## 开发环境
......@@ -28,7 +28,7 @@ OpenHarmony轻量和小型系统适用于内存较小的IOT设备(参考内存
## 开发板
本文基于以下两款典型开发板进行开发介绍 :Hi3861 WLAN模组、Hi3516DV300。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-ide-lite-board-introduction.md),开发者可根据需要自行购买开发板。
本文基于以下两款典型开发板进行开发介绍 :Hi3861 WLAN模组、Hi3516DV300。开发板的具体外观和规格可参见[本文附录](../quick-start/quickstart-ide-lite-introduction-hi3861.md),开发者可根据需要自行购买开发板。
## 开发流程
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册