提交 b0cf6754 编写于 作者: G Gloria

Update docs against master changes

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 877804c8
......@@ -35,8 +35,8 @@ Assume that your application has two UIAbility components: EntryAbility and Func
let want = {
deviceId: '', // An empty deviceId indicates the local device.
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
moduleName: 'func', // moduleName is optional.
abilityName: 'FuncAbility',
parameters: { // Custom information.
info: 'From the Index page of EntryAbility',
},
......@@ -100,8 +100,8 @@ When starting FuncAbility from EntryAbility, you may want the result to be retur
let want = {
deviceId: '', // An empty deviceId indicates the local device.
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
moduleName: 'func', // moduleName is optional.
abilityName: 'FuncAbility',
parameters: { // Custom information.
info: 'From the Index page of EntryAbility',
},
......@@ -123,8 +123,8 @@ When starting FuncAbility from EntryAbility, you may want the result to be retur
resultCode: RESULT_CODE,
want: {
bundleName: 'com.example.myapplication',
moduleName: 'func', // moduleName is optional.
abilityName: 'FuncAbility',
moduleName: 'func',
parameters: {
info: 'From the Index page of FuncAbility',
},
......@@ -296,9 +296,9 @@ If you want to obtain the return result when using implicit Want to start the UI
let abilityResult = {
resultCode: RESULT_CODE,
want: {
bundleName: 'com.example.myapplication',
bundleName: 'com.example.funcapplication',
moduleName: 'entry', // moduleName is optional.
abilityName: 'EntryAbility',
moduleName: 'entry',
parameters: {
payResult: 'OKay',
},
......@@ -366,8 +366,8 @@ let context = ...; // UIAbilityContext
let want = {
deviceId: '', // An empty deviceId indicates the local device.
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
moduleName: 'func', // moduleName is optional.
abilityName: 'FuncAbility',
parameters: { // Custom information.
info: 'From the Index page of EntryAbility',
},
......@@ -384,7 +384,6 @@ context.startAbility(want, options).then(() => {
```
The display effect is shown below.
![](figures/start-uiability-floating-window.png)
## Starting a Specified Page of UIAbility
......@@ -401,9 +400,9 @@ When the initiator UIAbility starts another UIAbility, it usually needs to redir
let context = ...; // UIAbilityContext
let want = {
deviceId: '', // An empty deviceId indicates the local device.
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
moduleName: 'func', // moduleName is optional.
bundleName: 'com.example.funcapplication',
moduleName: 'entry', // moduleName is optional.
abilityName: 'EntryAbility',
parameters: { // Custom parameter used to pass the page information.
router: 'funcA',
},
......@@ -423,25 +422,25 @@ When the target UIAbility is started for the first time, in the **onWindowStageC
```ts
import UIAbility from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
import UIAbility from '@ohos.app.ability.UIAbility';
import Want from '@ohos.app.ability.Want';
import window from '@ohos.window';
export default class FuncAbility extends UIAbility {
funcAbilityWant;
funcAbilityWant: Want;
onCreate(want, launchParam) {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
// Receive the parameters passed by the initiator UIAbility.
this.funcAbilityWant = want;
}
onWindowStageCreate(windowStage: Window.WindowStage) {
onWindowStageCreate(windowStage: window.WindowStage) {
// Main window is created. Set a main page for this UIAbility.
let url = 'pages/Index';
if (this.funcAbilityWant?.parameters?.router) {
if (this.funcAbilityWant.parameters.router === 'funA') {
if (this.funcAbilityWant?.parameters?.router && this.funcAbilityWant.parameters.router === 'funcA') {
url = 'pages/Second';
}
}
windowStage.loadContent(url, (err, data) => {
...
});
......@@ -449,52 +448,91 @@ export default class FuncAbility extends UIAbility {
}
```
### Starting a Page When the Target UIAbility Is Not Started for the First Time
You start application A, and its home page is displayed. Then you return to the home screen and start application B. Now you need to start application A again from application B and access a specified page of application A. An example scenario is as follows: When you open the home page of the SMS application and return to the home screen, the SMS application is in the opened state with its home page. Then you open the home page of the Contacts application, access user A's details page, and touch the SMS icon to send an SMS message to user A. The SMS application is started again and the sending page is displayed.
![uiability_not_first_started](figures/uiability_not_first_started.png)
If the target UIAbility has been started, the initialization logic is not executed again. Instead, the **onNewWant()** lifecycle callback is directly triggered. To implement redirection, parse the required parameters in **onNewWant()**.
An example scenario is as follows:
1. A user opens the SMS application. The UIAbility instance of the SMS application is started, and the home page of the application is displayed.
2. The user returns to the home screen, and the SMS application switches to the background.
3. The user opens the Contacts application and finds a contact.
4. The user touches the SMS button next to the contact. The UIAbility instance of the SMS application is restarted.
5. Since the UIAbility instance of the SMS application has been started, the **onNewWant()** callback of the UIAbility is triggered, and the initialization logic such as **onCreate()** and **onWindowStageCreate()** is skipped.
```mermaid
sequenceDiagram
Participant U as User
Participant S as SMS app
Participant C as Contacts app
U->>S: Open the SMS app.
S-->>U: The home page of the SMS app is displayed.
U->>S: Return to the home screen.
S->>S: The SMS app enters the background.
U->>C: Open the Contacts app.
C-->>U: The page of the Contact app is displayed.
U->>C: Touch the SMS button next to a contact.
C->>S: Start the SMS app with Want.
S-->>U: The page for sending an SMS message to the contact is displayed.
```
In summary, when a UIAbility instance of application A has been created and the main page of the UIAbility instance is displayed, you need to start the UIAbility of application A from application B and access a different page.
The development procedure is as follows:
1. In the target UIAbility, the **Index** page is loaded by default. The UIAbility instance has been created, and the **onNewWant()** callback rather than **onCreate()** and **onWindowStageCreate()** will be invoked. In the **onNewWant()** callback, parse the **want** parameter and bind it to the global variable **globalThis**.
1. When the UIAbility instance of the SMS application is started for the first time, call [getUIContext()](../reference/apis/js-apis-window.md#getuicontext10) in the **onWindowStageCreate()** lifecycle callback to obtain the [UIContext](../reference/apis/js-apis-arkui-UIContext.md).
```ts
import UIAbility from '@ohos.app.ability.UIAbility'
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
import UIAbility from '@ohos.app.ability.UIAbility';
import Want from '@ohos.app.ability.Want';
import window from '@ohos.window';
import { Router, UIContext } from '@ohos.arkui.UIContext';
export default class EntryAbility extends UIAbility {
funcAbilityWant: Want;
uiContext: UIContext;
export default class FuncAbility extends UIAbility {
onNewWant(want, launchParam) {
// Receive the parameters passed by the initiator UIAbility.
globalThis.funcAbilityWant = want;
...
onWindowStageCreate(windowStage: window.WindowStage) {
// Main window is created. Set a main page for this UIAbility.
...
let windowClass: window.Window;
windowStage.getMainWindow((err, data) => {
if (err.code) {
console.error(`Failed to obtain the main window. Code is ${err.code}, message is ${err.message}`);
return;
}
windowClass = data;
this.uiContext = windowClass.getUIContext();
})
}
}
```
2. In FuncAbility, use the router module to implement redirection to the specified page on the **Index** page. Because the **Index** page of FuncAbility is active, the variable will not be declared again and the **aboutToAppear()** callback will not be triggered. Therefore, the page routing functionality can be implemented in the **onPageShow()** callback of the **Index** page.
2. Parse the **want** parameter passed in the **onNewWant()** callback of the UIAbility of the SMS application, call [getRouter()](../reference/apis/js-apis-arkui-UIContext.md#getrouter) in the **UIContext** class to obtain a [Router](../reference/apis/js-apis-arkui-UIContext.md#router) instance, and specify the target page. When the UIAbility instance of the SMS application is started again, the specified page of the UIAbility instance of the SMS application is displayed.
```ts
import router from '@ohos.router';
@Entry
@Component
struct Index {
onPageShow() {
let funcAbilityWant = globalThis.funcAbilityWant;
let url2 = funcAbilityWant?.parameters?.router;
if (url2 && url2 === 'funcA') {
router.replaceUrl({
url: 'pages/Second',
export default class EntryAbility extends UIAbility {
funcAbilityWant: Want;
uiContext: UIContext;
onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam) {
if (want?.parameters?.router && want.parameters.router === 'funcA') {
let funcAUrl = 'pages/Second';
let router: Router = this.uiContext.getRouter();
router.pushUrl({
url: funcAUrl
}).catch((err) => {
console.error(`Failed to push url. Code is ${err.code}, message is ${err.message}`);
})
}
}
// Page display.
build() {
...
}
}
```
> **NOTE**
......
......@@ -327,9 +327,11 @@ For details about how to implement persistent data storage, see [Application Dat
The **Want** object passed in by the widget host to the widget provider contains a flag that specifies whether the requested widget is normal or temporary.
- Normal widget: a widget persistently used by the widget host
- Normal widget: a widget persistently used by the widget host, for example, a widget added to the home screen.
- Temporary widget: a widget temporarily used by the widget host
- Temporary widget: a widget temporarily used by the widget host, for example, the widget displayed when you swipe up on a widget application.
Converting a temporary widget to a normal one: After you swipe up on a widget application, a temporary widget is displayed. If you touch the pin button on the widget, it is displayed as a normal widget on the home screen.
Data of a temporary widget will be deleted on the Widget Manager if the widget framework is killed and restarted. The widget provider, however, is not notified of the deletion and still keeps the data. Therefore, the widget provider needs to clear the data of temporary widgets proactively if the data has been kept for a long period of time. If the widget host has converted a temporary widget into a normal one, the widget provider should change the widget data from temporary storage to persistent storage. Otherwise, the widget data may be deleted by mistake.
......
......@@ -61,6 +61,7 @@
- Best Practices
- [Camera Photographing Sample](camera-shooting-case.md)
- [Camera Recording Sample](camera-recording-case.md)
- [Using Performance Improvement Features (for System Applications Only)](camera-preformance-imporvement.md)
- Image
- [Image Overview](image-overview.md)
- [Image Decoding](image-decoding.md)
......
......@@ -28,7 +28,6 @@ Read [AudioEncoder](../reference/native-apis/_audio_encoder.md) for the API refe
Refer to the code snippet below to complete the entire audio encoding process, including creating an encoder, setting encoding parameters (such as the sampling rate, bit rate, and number of audio channels), and starting, refreshing, resetting, and destroying the encoder.
During application development, you must call the APIs in the defined sequence. Otherwise, an exception or undefined behavior may occur.
For details about the complete code, see [Sample](https://gitee.com/openharmony/multimedia_av_codec/blob/master/test/nativedemo/audio_demo/avcodec_audio_aac_encoder_demo.cpp).
......@@ -47,12 +46,10 @@ The figure below shows the call relationship of audio encoding.
const char *name = OH_AVCapability_GetName(capability);
OH_AVCodec *audioEnc = OH_AudioEncoder_CreateByName(name);
```
```cpp
// Create an encoder by MIME type.
OH_AVCodec *audioEnc = OH_AudioEncoder_CreateByMime(OH_AVCODEC_MIMETYPE_AUDIO_AAC);
```
```cpp
// Initialize the queues.
class AEncSignal {
......@@ -71,7 +68,6 @@ The figure below shows the call relationship of audio encoding.
};
AEncSignal *signal_ = new AEncSignal();
```
2. Call **OH_AudioEncoder_SetCallback()** to set callback functions.
Register the **OH_AVCodecAsyncCallback** struct that defines the following callback function pointers:
......@@ -128,7 +124,6 @@ The figure below shows the call relationship of audio encoding.
// Set the asynchronous callbacks.
int32_t ret = OH_AudioEncoder_SetCallback(audioEnc, cb, userData);
```
3. Call **OH_AudioEncoder_Configure** to configure the encoder.
The following options are mandatory: sampling rate, bit rate, number of audio channels, audio channel type, and bit depth. The maximum input length is optional.
......@@ -144,15 +139,15 @@ The figure below shows the call relationship of audio encoding.
// (Mandatory) Configure the audio sampling rate.
constexpr uint32_t DEFAULT_SMAPLERATE = 44100;
// (Mandatory) Configure the audio bit rate.
constexpr uint32_t DEFAULT_BITRATE = 32000;
constexpr uint64_t DEFAULT_BITRATE = 32000;
// (Mandatory) Configure the number of audio channels.
constexpr uint32_t DEFAULT_CHANNEL_COUNT = 2;
// (Mandatory) Configure the audio channel type.
constexpr AudioChannelLayout CHANNEL_LAYOUT =AudioChannelLayout::STEREO;
// (Mandatory) Configure the audio bit depth. Only SAMPLE_S16LE and SAMPLE_S32LE are available for FLAC encoding.
constexpr OH_BitsPerSample SAMPLE_FORMAT =OH_BitsPerSample::SAMPLE_S32LE;
// (Mandatory) Configure the audio bit depth. Only SAMPLE_S32P is available for AAC encoding.
constexpr OH_BitsPerSample SAMPLE_AAC_FORMAT =OH_BitsPerSample::SAMPLE_S32P;
// (Mandatory) Configure the audio bit depth. Only SAMPLE_F32P is available for AAC encoding.
constexpr OH_BitsPerSample SAMPLE_AAC_FORMAT = OH_BitsPerSample::SAMPLE_F32LE;
// Configure the audio compliance level. The default value is 0, and the value ranges from -2 to 2.
constexpr int32_t COMPLIANCE_LEVEL = 0;
// (Mandatory) Configure the audio sampling precision. SAMPLE_S16LE, SAMPLE_S24LE, and SAMPLE_S32LE are available.
......@@ -162,7 +157,7 @@ The figure below shows the call relationship of audio encoding.
OH_AVFormat *format = OH_AVFormat_Create();
// Set the format.
OH_AVFormat_SetIntValue(format,MediaDescriptionKey::MD_KEY_SAMPLE_RATE.data(),DEFAULT_SMAPLERATE);
OH_AVFormat_SetIntValue(format,MediaDescriptionKey::MD_KEY_BITRATE.data(), DEFAULT_BITRATE);
OH_AVFormat_SetLongValue(format,MediaDescriptionKey::MD_KEY_BITRATE.data(), DEFAULT_BITRATE);
OH_AVFormat_SetIntValue(format,MediaDescriptionKey::MD_KEY_CHANNEL_COUNT.data(),DEFAULT_CHANNEL_COUNT);
OH_AVFormat_SetIntValue(format,MediaDescriptionKey::MD_KEY_MAX_INPUT_SIZE.data(),DEFAULT_MAX_INPUT_SIZE);
OH_AVFormat_SetLongValue(format,MediaDescriptionKey::MD_KEY_CHANNEL_LAYOUT.data(),CHANNEL_LAYOUT);
......@@ -180,13 +175,11 @@ The figure below shows the call relationship of audio encoding.
// Exception handling.
}
```
4. Call **OH_AudioEncoder_Prepare()** to prepare internal resources for the encoder.
```c++
OH_AudioEncoder_Prepare(audioEnc);
```
5. Call **OH_AudioEncoder_Start()** to start the encoder.
```c++
......@@ -202,7 +195,6 @@ The figure below shows the call relationship of audio encoding.
// Exception handling.
}
```
6. Call **OH_AudioEncoder_PushInputData()** to write the data to encode.
To indicate the End of Stream (EOS), pass in the **AVCODEC_BUFFER_FLAGS_EOS** flag.
......@@ -225,6 +217,7 @@ The figure below shows the call relationship of audio encoding.
**NOTE**: If **FRAME_SIZE** is not set to **1024** for AAC encoding, an error code is returned. In the case of FLAC encoding, if **FRAME_SIZE** is set to a value greater than the value listed in the table for a given sampling rate, an error code is returned; if **FRAME_SIZE** is set to a value less than the value listed, the encoded file may be damaged.
```c++
constexpr int32_t FRAME_SIZE = 1024; // AAC encoding
constexpr int32_t DEFAULT_CHANNEL_COUNT =2;
......@@ -270,7 +263,6 @@ The figure below shows the call relationship of audio encoding.
break;
}
```
8. (Optional) Call **OH_AudioEncoder_Flush()** to refresh the encoder.
After **OH_AudioEncoder_Flush()** is called, the current encoding queue is cleared.
......@@ -294,7 +286,6 @@ The figure below shows the call relationship of audio encoding.
// Exception handling.
}
```
9. (Optional) Call **OH_AudioEncoder_Reset()** to reset the encoder.
After **OH_AudioEncoder_Reset()** is called, the encoder returns to the initialized state. To continue encoding, you must call **OH_AudioEncoder_Configure()** and then **OH_AudioEncoder_Start()**.
......
# Using Performance Improvement Features (for System Applications Only)
The camera startup performance is affected by time-consuming operations such as power-on of underlying components and initialization of the process pipeline. To improve the camera startup speed and thumbnail display speed, OpenHarmony introduces some features. The capabilities of these features are related to underlying components. You need to check whether these capabilities are supported before using them.
These features are involved in the processes of starting the camera device, configuring streams, and taking photos. This topic describes the three scenarios.
## Deferred Stream Configuration
A typical camera startup process includes starting the camera device, configuring a data stream, and starting the data stream. Before configuring the data stream, you need to obtain the surface ID of the **\<XComponent>**.
The deferred stream configuration feature decouples stream configuration and start from the surface. Before the **\<XComponent>** provides the surface for the camera application, the system configures and starts the stream. This way, the surface only needs to be available before the stream is started. This improves the startup speed and prevents the implementation of other startup optimization schemas from being affected.
![deferred-surface-scene](figures/deferred-surface-scene.png)
Before optimization: Stream configuration depends on a **Surface** object, which is available after UI loading is complete. In other words, you can create a session, configure input and output streams, and start the session only after the UI is loaded. The camera HDI is responsible for stream configuration.
After optimization: Stream configuration does not depend on the **Surface** object. UI loading and stream configuration are executed concurrently. After the parameters are prepared, you can create a session.
### Available APIs
Read [Camera](../reference/apis/js-apis-camera.md) for the API reference.
| API| Description|
| ---- | ---- |
| createDeferredPreviewOutput(profile: Profile): Promise\<PreviewOutput> | Creates a deferred **PreviewOutput** instance and adds it to the data stream instead of a common **PreviewOutput** instance during stream configuration.|
| addDeferredSurface(surfaceId: string): Promise\<void> | Adds a surface for delayed preview. This API can run after **session.commitConfig()** or **session.start()** is called.|
### Development Example
The figure below shows the recommended API call process.
![](figures/deferred-surface-sequence-diagram.png)
```js
import camera from '@ohos.multimedia.camera';
function async preview(context: Context, cameraInfo: camera.Device, previewProfile: camera.Profile, photoProfile: camera.Profile, surfaceId: string): Promise<void> {
const cameraManager: camera.CameraManager = camera.getCameraManager(context);
const cameraInput camera.CameraInput = await cameraManager.createCameraInput(cameraInfo)
const previewOutput: camera.PreviewOutput = await cameraManager.createDeferredPreviewOutput(previewProfile);
const photoOutput: camera.PhotoOutput = await cameraManager.createPhotoOutput(photoProfile);
const session: camera.CaptureSession = await this.mCameraManager.createCaptureSession();
await session.beginConfig();
await session.addInput(cameraInput);
await session.addOutput(previewOutput);
await session.addOutput(photoOutput);
await session.commitConfig();
await session.start();
await previewOutput.addDeferredSurface(surfaceId);
}
```
## Quick Thumbnail
The photographing performance depends on the algorithm processing speed. A complex algorithm chain provides better image effect while requiring longer processing time.
To improve the photographing speed perceived by end users, the quick thumbnail feature is introduced. When the user takes a photo, a thumbnail is output and reported to the camera application for display before a real image is reported.
In this way, the photographing process is optimized, which fulfills the processing requirements of the post-processing algorithm without blocking the photographing speed of the foreground.
### Available APIs
Read [Camera](../reference/apis/js-apis-camera.md) for the API reference.
| API| Description|
| ---- | ---- |
| isQuickThumbnailSupported() : boolean | Checks whether the quick thumbnail feature is supported.|
| enableQuickThumbnail(enabled:bool): void | Enables or disables the quick thumbnail feature.|
| on(type: 'quickThumbnail', callback: AsyncCallback\<image.PixelMap>): void | Listens for camera thumbnails.|
> **NOTE**
>
> - **isQuickThumbnailSupported** and **enableQuickThumbnail** must be called after **CaptureSession.addOutput** and **CaptureSession.addInput** but before **CaptureSession.commitConfig()**.
> - **on()** takes effect after **enableQuickThumbnail(true)** is called.
### Development Example
The figure below shows the recommended API call process.
![](figures/quick-thumbnail-sequence-diagram.png)
```js
import camera from '@ohos.multimedia.camera'
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
// Create a CaptureSession instance.
this.captureSession = await this.cameraManager.createCaptureSession()
// Start configuration for the session.
await this.captureSession.beginConfig()
// Add a CameraInput instance to the session.
this.cameraInput = await this.cameraManager.createCameraInput(cameras[0])
await this.cameraInput.open()
await this.captureSession.addInput(this.cameraInput)
// Add a PhotoOutput instance to the session.
this.photoOutPut = await this.cameraManager.createPhotoOutput(photoProfile, surfaceId)
await this.captureSession.addOutput(this.photoOutPut)
boolean isSupported = this.photoOutPut.isQuickThumbnailSupported()
if (isSupported) {
// Enable the quick thumbnail feature.
this.photoOutPut.enableQuickThumbnail(true)
this.photoOutPut.on('quickThumbnail', (err, pixelmap) => {
if (err || pixelmap === undefined) {
Logger.error(this.tag, 'photoOutPut on thumbnail failed ')
return
}
// Display or save the PixelMap instance.
this.showOrSavePicture(pixelmap)
})
}
```
## Prelaunch
Generally, the startup of the camera application is triggered when the user touches the camera icon on the home screen. The home screen senses the touch event and instructs the application manager to start the camera application. This takes a relatively long time. After the camera application is started, the camera startup process starts. A typical camera startup process includes starting the camera device, configuring a data stream, and starting the data stream, which is also time-consuming.
The prelaunch feature triggers the action of starting the camera device before the camera application is started. In other words, when the user touches the camera icon on the home screen, the system starts the camera device. At this time, the camera application is not started yet. The figure below shows the camera application process before and after the prelaunch feature is introduced.
![prelaunch-scene](figures/prelaunch-scene.png)
### Available APIs
Read [Camera](../reference/apis/js-apis-camera.md) for the API reference.
| API| Description|
| ---- | ---- |
| isPrelaunchSupported(camera: CameraDevice) : boolean | Checks whether the camera supports prelaunch.|
| setPrelaunchConfig(prelaunchConfig: PrelaunchConfig) : void | Sets the prelaunch parameters.|
| prelaunch() : void | Prelaunches the camera. This API is called when a user clicks the system camera icon to start the camera application.|
### Development Example
The figure below shows the recommended API call process.
![](figures/prelaunch-sequence-diagram.png)
- **Home screen**
```js
import camera from '@ohos.multimedia.camera'
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
try {
this.cameraManager.prelaunch();
} catch (error) {
console.error(`catch error: Code: ${error.code}, message: ${error.message}`)
}
```
- **Camera application**
To use the prelaunch feature, the camera application must configure the **ohos.permission.CAMERA** permission.
For details about how to request and verify the permissions, see [Permission Application Guide](../security/accesstoken-guidelines.md).
```js
import camera from '@ohos.multimedia.camera'
this.cameraManager = camera.getCameraManager(globalThis.abilityContext);
let cameras = this.cameraManager.getSupportedCameras()
if(this.cameraManager.isPrelaunchSupported(cameras[0])) {
try {
this.cameraManager.setPrelaunchConfig({cameraDevice: cameras[0]});
} catch (error) {
console.error(`catch error: Code: ${error.code}, message: ${error.message}`)
}
}
```
......@@ -72,7 +72,7 @@ let AVRecorderConfig = {
audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
profile : AVRecorderProfile,
url : 'fd://', // Before passing in a file descriptor to this parameter, the file must be created by the caller and granted with the read and write permissions. Example value: eg.fd://45--file:///data/media/01.mp4.
url : 'fd://', // Before passing in a file descriptor to this parameter, the file must be created by the caller and granted with the read and write permissions. Example value: fd://45--file:///data/media/01.mp4.
rotation: 0, // The value can be 0, 90, 180, or 270. If any other value is used, prepare() reports an error.
location : { latitude : 30, longitude : 130 }
}
......
......@@ -161,7 +161,7 @@ startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\
Starts an ability. This API uses an asynchronous callback to return the result when the ability is terminated. The following situations may be possible for a started ability:
- Normally, you can call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability. The result is returned to the caller.
- If an exception occurs, for example, the ability is killed, an exception message, in which **resultCode** is **-1**, is returned to the caller.
- If different applications call this API to start an ability that uses the sington mode and then call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability, the normal result is returned to the last caller, and an exception message, in which **resultCode** is **-1**, is returned to others.
- If different applications call this API to start an ability that uses the singleton mode and then call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability, the normal result is returned to the last caller, and an exception message, in which **resultCode** is **-1**, is returned to others.
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
......@@ -214,7 +214,7 @@ startAbilityForResult(parameter: StartAbilityParameter): Promise\<AbilityResult>
Starts an ability. This API uses a promise to return the result when the ability is terminated. The following situations may be possible to an ability after it is started:
- Normally, you can call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability. The result is returned to the caller.
- If an exception occurs, for example, the ability is killed, an exception message, in which **resultCode** is **-1**, is returned to the caller.
- If different applications call this API to start an ability that uses the sington mode and then call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability, the normal result is returned to the last caller, and an exception message, in which **resultCode** is **-1**, is returned to others.
- If different applications call this API to start an ability that uses the singleton mode and then call [terminateSelfWithResult](#featureabilityterminateselfwithresult7) to terminate the ability, the normal result is returned to the last caller, and an exception message, in which **resultCode** is **-1**, is returned to others.
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
......
......@@ -39,7 +39,7 @@ Enumerates the initial ability launch reasons. You can use it together with [onC
| CALL | 2 | The ability is started by calling [startAbilityByCall](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartabilitybycall).|
| CONTINUATION | 3 | The ability is started by means of cross-device migration.|
| APP_RECOVERY | 4 | The ability is automatically started when the application is restored from a fault.|
| SHARE<sup>10+</sup> | 5 | The ability is started by calling [acquireShareData](js-apis-app-ability-abilityManager.md#acquiresharedata).|
| SHARE<sup>10+</sup> | 5 | The ability is started by means of atomic service sharing.|
**Example**
......
......@@ -392,6 +392,8 @@ Called by a system dialog box to obtain shared data, which is set by the target
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
......@@ -433,6 +435,8 @@ Called by a system dialog box to obtain shared data, which is set by the target
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
......
......@@ -202,7 +202,7 @@ Called to save data during the ability migration preparation process.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes| **want** parameter.|
| wantParam | {[key:&nbsp;string]:&nbsp;Object} | Yes| **want** parameter.|
**Return value**
......@@ -289,7 +289,7 @@ Called when the framework automatically saves the UIAbility state in the case of
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| reason | [AbilityConstant.StateType](js-apis-app-ability-abilityConstant.md#abilityconstantstatetype) | Yes| Reason for triggering the callback to save the UIAbility state.|
| wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes| **want** parameter.|
| wantParam | {[key:&nbsp;string]:&nbsp;Object} | Yes| **want** parameter.|
**Return value**
......@@ -315,7 +315,7 @@ class MyUIAbility extends UIAbility {
onShare(wantParam:{ [key: string]: Object }): void;
Called when this UIAbility sets data to share. **ohos.extra.param.key.contentTitle** indicates the title of the content to share in the sharing box, **ohos.extra.param.key.shareAbstract** provides an abstract description of the content, and **ohos.extra.param.key.shareUrl** indicates the online address of the service. You need to set these three items as objects, with the key set to **title**, **abstract**, and **url**, respectively.
Called by this UIAbility to set data to share. **ohos.extra.param.key.shareUrl** indicates the online address of the service.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
......@@ -332,9 +332,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
class MyUIAbility extends UIAbility {
onShare(wantParams) {
console.log('onShare');
wantParams['ohos.extra.param.key.contentTitle'] = {title: "OA"};
wantParams['ohos.extra.param.key.shareAbstract'] = {abstract: "communication for company employee"};
wantParams['ohos.extra.param.key.shareUrl'] = {url: "oa.example.com"};
wantParams['ohos.extra.param.key.shareUrl'] = 'example.com';
}
}
```
......
......@@ -3076,7 +3076,7 @@ Checks whether the fixed volume mode is enabled. When the fixed volume mode is e
**Example**
```js
bool volumeAdjustSwitch = audioVolumeGroupManager.isVolumeUnadjustable();
let volumeAdjustSwitch = audioVolumeGroupManager.isVolumeUnadjustable();
console.info(`Whether it is volume unadjustable: ${volumeAdjustSwitch}.`);
```
......@@ -5790,13 +5790,13 @@ audioRenderer.getCurrentOutputDevices((err, deviceInfo) => {
console.error(`getCurrentOutputDevices Fail: ${err}`);
} else {
console.info(`DeviceInfo id: ${deviceInfo.id}`);
console.info(`DeviceInfo type: ${descriptor.deviceType}`);
console.info(`DeviceInfo role: ${descriptor.deviceRole}`);
console.info(`DeviceInfo name: ${descriptor.name}`);
console.info(`DeviceInfo address: ${descriptor.address}`);
console.info(`DeviceInfo samplerates: ${descriptor.sampleRates[0]}`);
console.info(`DeviceInfo channelcounts: ${descriptor.channelCounts[0]}`);
console.info(`DeviceInfo channelmask: ${descriptor.channelMasks}`);
console.info(`DeviceInfo type: ${deviceInfo.deviceType}`);
console.info(`DeviceInfo role: ${deviceInfo.deviceRole}`);
console.info(`DeviceInfo name: ${deviceInfo.name}`);
console.info(`DeviceInfo address: ${deviceInfo.address}`);
console.info(`DeviceInfo samplerates: ${deviceInfo.sampleRates[0]}`);
console.info(`DeviceInfo channelcounts: ${deviceInfo.channelCounts[0]}`);
console.info(`DeviceInfo channelmask: ${deviceInfo.channelMasks}`);
}
});
```
......@@ -5819,13 +5819,13 @@ Obtains the output device descriptors of the audio streams. This API uses a prom
```js
audioRenderer.getCurrentOutputDevices().then((deviceInfo) => {
console.info(`DeviceInfo id: ${deviceInfo.id}`);
console.info(`DeviceInfo type: ${descriptor.deviceType}`);
console.info(`DeviceInfo role: ${descriptor.deviceRole}`);
console.info(`DeviceInfo name: ${descriptor.name}`);
console.info(`DeviceInfo address: ${descriptor.address}`);
console.info(`DeviceInfo samplerates: ${descriptor.sampleRates[0]}`);
console.info(`DeviceInfo channelcounts: ${descriptor.channelCounts[0]}`);
console.info(`DeviceInfo channelmask: ${descriptor.channelMasks}`);
console.info(`DeviceInfo type: ${deviceInfo.deviceType}`);
console.info(`DeviceInfo role: ${deviceInfo.deviceRole}`);
console.info(`DeviceInfo name: ${deviceInfo.name}`);
console.info(`DeviceInfo address: ${deviceInfo.address}`);
console.info(`DeviceInfo samplerates: ${deviceInfo.sampleRates[0]}`);
console.info(`DeviceInfo channelcounts: ${deviceInfo.channelCounts[0]}`);
console.info(`DeviceInfo channelmask: ${deviceInfo.channelMasks}`);
}).catch((err) => {
console.error(`Get current output devices Fail: ${err}`);
});
......@@ -6073,7 +6073,7 @@ Subscribes to audio output device change events.
**Example**
```js
audioRenderer.on('outputDeviceChange', (deviceChangeInfo) => {
audioRenderer.on('outputDeviceChange', (err, deviceChangeInfo) => {
if (err) {
console.error(`Subscribes output device change event callback Fail: ${err}`);
} else {
......@@ -6105,7 +6105,7 @@ Unsubscribes from audio output device event changes.
**Example**
```js
audioRenderer.off('outputDeviceChange', (deviceChangeInfo) => {
audioRenderer.off('outputDeviceChange', (err,deviceChangeInfo) => {
if (err) {
console.error(`Unsubscribes output device change event callback Fail: ${err}`);
} else {
......
......@@ -15,11 +15,11 @@ The **AbilityInfo** module defines the ability information. A system application
| bundleName | string | Yes | No | Bundle name. |
| moduleName | string | Yes | No | Name of the HAP file to which the ability belongs. |
| name | string | Yes | No | Ability name. |
| label | string | Yes | No | Ability name visible to users. |
| label | string | Yes | No | Resource descriptor of the ability name visible to users. Example: **"label": "$string: mainability_description"**. |
| labelId | number | Yes | No | ID of the ability label. |
| description | string | Yes | No | Ability description. |
| descriptionId | number | Yes | No | ID of the ability description. |
| icon | string | Yes | No | Index of the ability icon resource file. |
| icon | string | Yes | No | Resource descriptor of the ability icon. Example: **"icon": "$media:icon"**. |
| iconId | number | Yes | No | ID of the ability icon. |
| process | string | Yes | No | Process in which the ability runs. If this parameter is not set, the bundle name is used.|
| exported | boolean | Yes | No | Whether the ability can be called by other bundles. |
......
......@@ -665,7 +665,7 @@ if(this.cameraManager.isPrelaunchSupported(cameras[0])) {
prelaunch(): void
Prelaunches the camera. This API is called when the camera application is started after a user clicks the system camera icon.
Prelaunches the camera. This API is called when a user clicks the system camera icon to start the camera application.
**System API**: This is a system API.
......@@ -2726,7 +2726,7 @@ previewOutput.on('error', (previewOutputError) => {
addDeferredSurface(surfaceId: string): void
Adds a surface for delayed preview. This API can run after **session.commitConfig()** is used to commit the configuration for a stream and **session.start()** is used to start the stream.
Adds a surface for delayed preview. This API can run after **session.commitConfig()** or **session.start()** is called.
**System API**: This is a system API.
......
......@@ -21,7 +21,7 @@ import effectKit from '@ohos.effectKit';
## effectKit.createEffect
createEffect(source: image.PixelMap): Filter
Creates a **Filter** instance based on the pixel map.
Creates a **Filter** instance based on a pixel map.
**System capability**: SystemCapability.Multimedia.Image.Core
......@@ -53,7 +53,7 @@ image.createPixelMap(color, opts).then((pixelMap) => {
createColorPicker(source: image.PixelMap): Promise\<ColorPicker>
Creates a **ColorPicker** instance based on the pixel map. This API uses a promise to return the result.
Creates a **ColorPicker** instance based on a pixel map. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Image.Core
......@@ -83,11 +83,46 @@ image.createPixelMap(color, opts).then((pixelMap) => {
})
```
## effectKit.createColorPicker<sup>10+</sup>
createColorPicker(source: image.PixelMap, region: Array\<number>): Promise\<ColorPicker>
Creates a **ColorPicker** instance for the selected region based on a pixel map. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Image.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------- | ---- | -------------------------- |
| source | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | **PixelMap** instance created by the image module. An instance can be obtained by decoding an image or directly created. For details, see [Image Overview](../../media/image-overview.md).|
| region | Array\<number> | Yes | Region of the image from which the color is picked.<br>The array consists of four elements, representing the left, top, right, and bottom positions of the image, respectively. The value of each element must be in the range [0, 1]. The leftmost and topmost positions of the image correspond to 0, and the rightmost and bottom positions correspond to 1. In the array, the third element must be greater than the first element, and the fourth element must be greater than the second element.<br>If no value is passed, the default value [0, 0, 1, 1] is used, indicating that the color region is the entire image.|
**Return value**
| Type | Description |
| ---------------------- | -------------- |
| Promise\<[ColorPicker](#colorpicker)> | Promise used to return the **ColorPicker** instance created.|
**Example**
```js
import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelMap) => {
effectKit.createColorPicker(pixelMap, [0, 0, 0.5, 0.5]).then(colorPicker => {
console.info("color picker=" + colorPicker);
}).catch(ex => console.error(".error=" + ex.toString()))
})
```
## effectKit.createColorPicker
createColorPicker(source: image.PixelMap, callback: AsyncCallback\<ColorPicker>): void
Creates a **ColorPicker** instance based on the pixel map. This API uses an asynchronous callback to return the result.
Creates a **ColorPicker** instance based on a pixel map. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image.Core
......@@ -116,6 +151,40 @@ image.createPixelMap(color, opts).then((pixelMap) => {
})
```
## effectKit.createColorPicker<sup>10+</sup>
createColorPicker(source: image.PixelMap, region:Array\<number>, callback: AsyncCallback\<ColorPicker>): void
Creates a **ColorPicker** instance for the selected region based on a pixel map. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Image.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------ | ---- | -------------------------- |
| source | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes |**PixelMap** instance created by the image module. An instance can be obtained by decoding an image or directly created. For details, see [Image Overview](../../media/image-overview.md). |
| region | Array\<number> | Yes | Region of the image from which the color is picked.<br>The array consists of four elements, representing the left, top, right, and bottom positions of the image, respectively. The value of each element must be in the range [0, 1]. The leftmost and topmost positions of the image correspond to 0, and the rightmost and bottom positions correspond to 1. In the array, the third element must be greater than the first element, and the fourth element must be greater than the second element.<br>If no value is passed, the default value [0, 0, 1, 1] is used, indicating that the color region is the entire image.|
| callback | AsyncCallback\<[ColorPicker](#colorpicker)> | Yes | Callback used to return the **ColorPicker** instance created.|
**Example**
```js
import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelMap) => {
effectKit.createColorPicker(pixelMap, [0, 0, 0.5, 0.5], (error, colorPicker) => {
if (error) {
console.log('Failed to create color picker.');
} else {
console.log('Succeeded in creating color picker.');
}
})
})
```
## Color
A class that stores the color picked.
......@@ -124,10 +193,10 @@ A class that stores the color picked.
| Name | Type | Readable| Writable| Description |
| ------ | ----- | ---- | ---- | ---------------- |
| red | number | Yes | No | Value of the red component. |
| green | number | Yes | No | Value of the green component. |
| blue | number | Yes | No | Value of the blue component. |
| alpha | number | Yes | No | Value of the alpha component. |
| red | number | Yes | No | Value of the red component. The value range is [0x0, 0xFF]. |
| green | number | Yes | No | Value of the green component. The value range is [0x0, 0xFF]. |
| blue | number | Yes | No | Value of the blue component. The value range is [0x0, 0xFF]. |
| alpha | number | Yes | No | Value of the alpha component. The value range is [0x0, 0xFF]. |
## ColorPicker
......@@ -250,10 +319,16 @@ console.log('get average color =' + color);
isBlackOrWhiteOrGrayColor(color: number): boolean
Checks whether this image is black, white, and gray.
Checks whether a color is black, white, and gray.
**System capability**: SystemCapability.Multimedia.Image.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------- | ---- | -------------------------- |
| color| number | Yes | Color to check. The value range is [0x0, 0xFFFFFFFF].|
**Return value**
| Type | Description |
......
......@@ -145,8 +145,8 @@ Inserts an element at the specified position in this container.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| element | T | Yes| Target element.|
| index | number | Yes| Index of the position where the element is to be inserted.|
| element | T | Yes| Target element.|
**Error codes**
......
......@@ -1781,7 +1781,7 @@ let AVRecorderConfig = {
audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
profile : AVRecorderProfile,
url : 'fd://', // Before passing in an FD to this parameter, the file must be created by the caller and granted with the read and write permissions. Example value: eg.fd://45.
url : 'fd://', // Before passing in an FD to this parameter, the file must be created by the caller and granted with the read and write permissions. Example value: fd://45.
rotation: 0, // The value can be 0, 90, 180, or 270. If any other value is used, prepare() reports an error.
location : { latitude : 30, longitude : 130 }
}
......@@ -1852,7 +1852,7 @@ let AVRecorderConfig = {
audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
profile : AVRecorderProfile,
url : 'fd://', // Before passing in an FD to this parameter, the file must be created by the caller and granted with the read and write permissions. Example value: eg.fd://45.
url : 'fd://', // Before passing in an FD to this parameter, the file must be created by the caller and granted with the read and write permissions. Example value: fd://45.
rotation: 0, // The value can be 0, 90, 180, or 270. If any other value is used, prepare() reports an error.
location : { latitude : 30, longitude : 130 }
}
......
# @ohos.resourceschedule.deviceStandby (Device Standby)
A device enters standby mode if it is unused for a long period of time or after the Power button is pressed. The standby mode prolongs the battery life without affecting the use of applications. The **deviceStandby** module provides APIs for you to check whether a device is in standby mode and request or cancel standby resource control for an application.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import deviceStandby from '@ohos.resourceschedule.deviceStandby';
```
## deviceStandby.getExemptedApps
getExemptedApps(resourceTypes: number, callback: AsyncCallback<Array&lt;ExemptedAppInfo&gt;>): void;
Obtains the list of applications that can still use resources of the specified types when the device is in standby mode. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------ |
| [ResourceTypes](#resourcetype)|number | Yes | Types of resources that can be used.|
| callback | AsyncCallback<Array&lt;[ExemptedAppInfo](#exemptedappinfo)&gt;> | Yes |Callback used to return the exempted application information.|
**Error codes**
For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
| ID | Error Message |
| ---- | --------------------- |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
| 9800003 | Inner transact failed. |
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed. |
**Example**
```js
try{
deviceStandby.getExemptedApps(resourceTypes, (err, res) => {
if (err) {
console.log('DEVICE_STANDBY getExemptedApps callback failed. code is: ' + err.code + ',message is: ' + err.message);
} else {
console.log('DEVICE_STANDBY getExemptedApps callback success.');
for (let i = 0; i < res.length; i++) {
console.log('DEVICE_STANDBY getExemptedApps callback result ' + JSON.stringify(res[i]));
}
}
});
} catch (error) {
console.log('DEVICE_STANDBY getExemptedApps throw error, code is: ' + error.code + ',message is: ' + error.message);
}
```
## deviceStandby.getExemptedApps
getExemptedApps(resourceTypes: number): Promise<Array&lt;ExemptedAppInfo&gt;>;
Obtains the list of applications that can still use resources of the specified types when the device is in standby mode. This API uses a promise to return the result.
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------ |
| [ResourceTypes](#resourcetype)|number | Yes |Types of resources that can be used.|
**Return value**
| Type | Description |
| --------------------- | ---------------------------------------- |
| Promise<Array&lt;[ExemptedAppInfo](#exemptedappinfo)&gt;> | Promise used to return the exempted application information.|
**Error codes**
For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
| ID | Error Message |
| ---- | --------------------- |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
| 9800003 | Inner transact failed. |
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed. |
**Example**
```js
try{
deviceStandby.getExemptedApps(resourceTypes).then( res => {
console.log('DEVICE_STANDBY getExemptedApps promise success.');
for (let i = 0; i < res.length; i++) {
console.log('DEVICE_STANDBY getExemptedApps promise result ' + JSON.stringify(res[i]));
}
}).catch( err => {
console.log('DEVICE_STANDBY getExemptedApps promise failed. code is: ' + err.code + ',message is: ' + err.message);
});
} catch (error) {
console.log('DEVICE_STANDBY getExemptedApps throw error, code is: ' + error.code + ',message is: ' + error.message);
}
```
## deviceStandby.requestExemptionResource
requestExemptionResource(request: ResourceRequest): void;
Requests exemption, so that the application can use restricted resources when the device is in standby mode.
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------ |
| request |[ResourceRequest](#resourcerequest)| Yes | Request body.|
**Error codes**
For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
| ID | Error Message |
| ---- | --------------------- |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
| 9800003 | Inner transact failed. |
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed. |
**Example**
```js
let resRequest = {
resourceTypes: 1,
uid:10003,
name:"com.example.app",
duration:10,
reason:"apply",
};
// Promise mode
try{
deviceStandby.requestExemptionResource(resRequest).then( () => {
console.log('DEVICE_STANDBY requestExemptionResource promise succeeded.');
}).catch( err => {
console.log('DEVICE_STANDBY requestExemptionResource promise failed. code is: ' + err.code + ',message is: ' + err.message);
});
} catch (error) {
console.log('DEVICE_STANDBY requestExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message);
}
// Asynchronous callback mode
try{
deviceStandby.requestExemptionResource(resRequest, (err) => {
if (err) {
console.log('DEVICE_STANDBY requestExemptionResource callback failed. code is: ' + err.code + ',message is: ' + err.message);
} else {
console.log('DEVICE_STANDBY requestExemptionResource callback succeeded.');
}
});
} catch (error) {
console.log('DEVICE_STANDBY requestExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message);
}
```
## deviceStandby.releaseExemptionResource
releaseExemptionResource(request: ResourceRequest): void;
Cancels exemption for the application.
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------ |
| request |[ResourceRequest](#resourcerequest)| Yes | Request body.|
**Error codes**
For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
| ID | Error Message |
| ---- | --------------------- |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
| 9800003 | Inner transact failed. |
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed. |
**Example**
```js
let resRequest = {
resourceTypes: 1,
uid:10003,
name:"com.demo.app",
duration:10,
reason:"unapply",
};
// Promise mode
try{
deviceStandby.releaseExemptionResource(resRequest).then( () => {
console.log('DEVICE_STANDBY releaseExemptionResource promise succeeded.');
}).catch( err => {
console.log('DEVICE_STANDBY releaseExemptionResource promise failed. code is: ' + err.code + ',message is: ' + err.message);
});
} catch (error) {
console.log('DEVICE_STANDBY releaseExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message);
}
// Asynchronous callback mode
try{
deviceStandby.releaseExemptionResource(resRequest, (err) => {
if (err) {
console.log('DEVICE_STANDBY releaseExemptionResource callback failed. code is: ' + err.code + ',message is: ' + err.message);
} else {
console.log('DEVICE_STANDBY releaseExemptionResource callback succeeded.');
}
});
} catch (error) {
console.log('DEVICE_STANDBY releaseExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message);
}
```
## ResourceType
Enumerates the types of resources that can be used by exempted applications.
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby
**System API**: This is a system API.
|Name |Value |Description|
| ------------ | ------------ |--------------|
|NETWORK |1 |Network access resource.|
|RUNNING_LOCK |2 |CPU running lock resource.|
|TIMER |4 | Timer task resource.|
|WORK_SCHEDULER |8 | Work task resource.|
|AUTO_SYNC |16 | Automatic synchronization resource.|
|PUSH |32 | Push kit resource.|
|FREEZE |64 | Freezing application resource.|
## ExemptedAppInfo
Defines the information about an exempted application.
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby
**System API**: This is a system API.
|Name |Type | Mandatory |Description |
| ------------ | ------------ |------------ | ------------ |
|[resourceTypes](#resourcetype) | number | Yes |Types of resources that can be used. |
|name |string | Yes | Name of the application. |
|duration | number | Yes | Exemption duration.|
## ResourceRequest
Defines the message used to request to be an exempted application.
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby
**System API**: This is a system API.
|Name |Type | Mandatory |Description |
| ------------ | ------------ |------------| ------------ |
|[resourceTypes](#resourcetype) | number | Yes |Types of resources that can be used. |
|uid | number | Yes |UID of the application. |
|name |string | Yes | Name of the application. |
|duration | number | Yes | Exemption duration.|
|reason |string | Yes | Reason for the request. |
......@@ -143,72 +143,7 @@ The [Architecture SIG](https://gitee.com/openharmony/community/blob/master/sig/s
### License Requirements for Third-Party Open-Source Software
1. The software license must be clearly defined by the [Open Source Initiative (OSI)](https://opensource.org/osd-annotated).
2. The software license must be compatible with the license for the code repository.
3. The following licenses for third-party open-source software are recommended in the OpenHarmony project:
- Apache License 2.0
- Mulan Permissive Software License, Version 2
- BSD 2-clause
- BSD 3-clause
- DOM4J License
- PostgreSQL License
- Eclipse Distribution License 1.0
- MIT
- ISC
- ICU
- University of Illinois/NCSA
- W3C Software License
- zlib/libpng
- Academic Free License 3.0
- Python Software Foundation License
- Python Imaging Library Software License
- Boost Software License Version 1.0
- WTF Public License
- UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
- Zope Public License 2.0
4. The following licenses for third-party open-source software are not recommended in the OpenHarmony project:
- GNU GPL 1, 2, 3
- GNU Affero GPL 3
- GNU LGPL 2, 2.1, 3
- QPL
- Sleepycat License
- Server Side Public License (SSPL) version 1
- Code Project Open License (CPOL)
- BSD-4-Clause/BSD-4-Clause (University of California-Specific)
- Facebook BSD+Patents license
- NPL 1.0/NPL 1.1
- The Solipsistic Eclipse Public License
- The "Don't Be A Dick" Public License
- JSON License
- Binary Code License (BCL)
- Intel Simplified Software License
- JSR-275 License
- Microsoft Limited Public License
- Amazon Software License (ASL)
- Java SDK for Satori RTM license
- Redis Source Available License (RSAL)
- Booz Allen Public License
- Creative Commons Non-Commercial
- Sun Community Source License 3.0
- Common Development and Distribution Licenses: CDDL 1.0 and CDDL 1.1
- Common Public License: CPL 1.0
- Eclipse Public License: EPL 1.0
- IBM Public License: IPL 1.0
- Mozilla Public Licenses: MPL 1.0, MPL 1.1, and MPL 2.0
- Sun Public License: SPL 1.0
- Open Software License 3.0
- Erlang Public License
- UnRAR License
- SIL Open Font License
- Ubuntu Font License Version 1.0
- IPA Font License Agreement v1.0
- Ruby License
- Eclipse Public License 2.0: EPL 2.0
If you want to introduce the software that complies with the unrecommended licenses listed in **4** or other licenses that are not mentioned, send an email to oh-legal@openatom.io.
For details, see [Licenses and Special License Review](licenses-and-special-license-review.md).
## Software Exit and Exit Principles
......
......@@ -25,7 +25,7 @@ Beta is a branch pulled from Master in the OpenHarmony community irregularly. Th
A tag version is a stable and reliable version created by applying patches to an LTS or a Release branch, with the purpose of fixing individual bugs, security vulnerabilities, and other necessary adaptation modifications.
The release versions are available in the [**Release Notes** folder](../).
The release versions are available in the [**Release Notes** folder](../release-notes).
## Lifecycle Policies
......@@ -40,6 +40,7 @@ The following table lists the maintenance schedule of the LTS and Release branch
| 1.0.1-Release | Release | 2021-03-30| 2022-03-30 | 2023-03-30|
| 3.0-LTS | LTS | 2021-09-30| 2023-09-30 | 2025-03-30|
| 3.1-Release | Release | 2022-03-30| 2023-03-30 | 2024-03-30|
| 3.2-Release | Release | 2022-4-9 | 2023-4-9 | 2024-4-9 |
Run the following commands to download the source code of each branch:
......@@ -47,7 +48,8 @@ Run the following commands to download the source code of each branch:
| ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1.0.1-Release | repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony_1.0.1_release -m default.xml --no-repo-verify<br>repo sync -c<br>repo forall -c 'git lfs pull' | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.1-Release -m default.xml --no-repo-verify<br>repo sync -c<br>repo forall -c 'git lfs pull' |
| 3.0-LTS | repo init -u https://gitee.com/openharmony/manifest.git -b OpenHarmony-3.0-LTS --no-repo-verify<br>repo sync -c<br>repo forall -c 'git lfs pull' | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.0-LTS --no-repo-verify<br>repo sync -c<br>repo forall -c 'git lfs pull' |
| 3.1-Release | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.1-Release -m default.xml --no-repo-verify<br>repo sync -c<br>repo forall -c 'git lfs pull' | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.1-Release -m default.xml --no-repo-verify<br>repo sync -c<br>repo forall -c 'git lfs pull' |
| 3.1-Release | repo init -u https://gitee.com/openharmony/manifest.git -b OpenHarmony-3.1-Release -m default.xml --no-repo-verify<br>repo sync -c<br>repo forall -c 'git lfs pull' | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.1-Release -m default.xml --no-repo-verify<br>repo sync -c<br>repo forall -c 'git lfs pull' |
| 3.2-Release | repo init -u https://gitee.com/openharmony/manifest.git -b OpenHarmony-3.2-Release -m default.xml --no-repo-verify<br>repo sync -c<br>repo forall -c 'git lfs pull' | repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.2-Release -m default.xml --no-repo-verify<br>repo sync -c<br>repo forall -c 'git lfs pull' |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册