提交 544bba55 编写于 作者: L luoying_ace 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into ly1111

Signed-off-by: Nluoying_ace <luoying19@huawei.com>
...@@ -8,14 +8,13 @@ ...@@ -8,14 +8,13 @@
- Quick Start - Quick Start
- Getting Started - Getting Started
- [Preparations](quick-start/start-overview.md) - [Preparations](quick-start/start-overview.md)
- [Getting Started with eTS in Stage Model](quick-start/start-with-ets-stage.md) - [Getting Started with ArkTS in Stage Model](quick-start/start-with-ets-stage.md)
- [Getting Started with eTS in FA Model](quick-start/start-with-ets-fa.md) - [Getting Started with ArkTS in FA Model](quick-start/start-with-ets-fa.md)
- [Getting Started with JavaScript in FA Model](quick-start/start-with-js-fa.md) - [Getting Started with JavaScript in FA Model](quick-start/start-with-js-fa.md)
- Development Fundamentals - Development Fundamentals
- [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md) - [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md)
- [Application Package Structure Configuration File (Stage Model)](quick-start/stage-structure.md) - [Application Package Structure Configuration File (Stage Model)](quick-start/stage-structure.md)
- [SysCap](quick-start/syscap.md) - [SysCap](quick-start/syscap.md)
- [HarmonyAppProvision Configuration File](quick-start/app-provision-structure.md)
- Development - Development
- [Ability Development](ability/Readme-EN.md) - [Ability Development](ability/Readme-EN.md)
......
# Ability Development # Ability Development
- [Ability Framework Overview](ability-brief.md) - [Ability Framework Overview](ability-brief.md)
- [Context Usage](context-userguide.md) - [Context Usage](context-userguide.md)
- FA Model - FA Model
...@@ -19,5 +20,3 @@ ...@@ -19,5 +20,3 @@
- [Ability Assistant Usage](ability-assistant-guidelines.md) - [Ability Assistant Usage](ability-assistant-guidelines.md)
- [ContinuationManager Development](continuationmanager.md) - [ContinuationManager Development](continuationmanager.md)
- [Test Framework Usage](ability-delegator.md) - [Test Framework Usage](ability-delegator.md)
# Page Ability Development # Page Ability Development
## Overview ## Overview
### Concepts ### Concepts
The Page ability implements the ArkUI and provides the capability of interacting with developers. When you create an ability in DevEco Studio, DevEco Studio automatically creates template code. The capabilities related to the Page ability are implemented through the **featureAbility**, and the lifecycle callbacks are implemented through the callbacks in **app.js** or **app.ets**.
The Page ability implements the ArkUI and provides the capability of interacting with developers. When you create an ability in DevEco Studio, DevEco Studio automatically creates template code.
The capabilities related to the Page ability are implemented through the **featureAbility**, and the lifecycle callbacks are implemented through the callbacks in **app.js** or **app.ets**.
### Page Ability Lifecycle ### Page Ability Lifecycle
**Ability lifecycle** Introduction to the Page ability lifecycle:
The Page ability lifecycle defines all states of a Page ability, such as **INACTIVE**, **ACTIVE**, and **BACKGROUND**. The Page ability lifecycle defines all states of a Page ability, such as **INACTIVE**, **ACTIVE**, and **BACKGROUND**.
...@@ -27,27 +31,30 @@ Description of ability lifecycle states: ...@@ -27,27 +31,30 @@ Description of ability lifecycle states:
- **BACKGROUND**: The Page ability runs in the background. After being re-activated, the Page ability enters the **ACTIVE** state. After being destroyed, the Page ability enters the **INITIAL** state. - **BACKGROUND**: The Page ability runs in the background. After being re-activated, the Page ability enters the **ACTIVE** state. After being destroyed, the Page ability enters the **INITIAL** state.
**The following figure shows the relationship between lifecycle callbacks and lifecycle states of the Page ability.** The following figure shows the relationship between lifecycle callbacks and lifecycle states of the Page ability.
![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) ![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png)
You can override the lifecycle callbacks provided by the Page ability in the **app.js** or **app.ets** file. Currently, the **app.js** file provides only the **onCreate** and **onDestroy** callbacks, and the **app.ets** file provides the full lifecycle callbacks. You can override the lifecycle callbacks provided by the Page ability in the **app.js** or **app.ets** file. Currently, the **app.js** file provides only the **onCreate** and **onDestroy** callbacks, and the **app.ets** file provides the full lifecycle callbacks.
### Launch Type ### Launch Type
The ability supports two launch types: singleton and multi-instance. The ability supports two launch types: singleton and multi-instance.
You can specify the launch type by setting **launchType** in the **config.json** file. You can specify the launch type by setting **launchType** in the **config.json** file.
**Table 1** Introduction to startup mode **Table 1** Startup modes
| Launch Type | Description |Description | | Launch Type | Description |Description |
| ----------- | ------- |---------------- | | ----------- | ------- |---------------- |
| standard | Multi-instance | A new instance is started each time an ability starts.| | standard | Multi-instance | A new instance is started each time an ability starts.|
| singleton | Singleton | Only one instance exists in the system. If an instance already exists when an ability is started, that instance is reused.| | singleton | Singleton | The ability has only one instance in the system. If an instance already exists when an ability is started, that instance is reused.|
By default, **singleton** is used. By default, **singleton** is used.
## Development Guidelines ## Development Guidelines
### Available APIs ### Available APIs
**Table 2** APIs provided by featureAbility **Table 2** APIs provided by featureAbility
...@@ -73,8 +80,7 @@ By default, **singleton** is used. ...@@ -73,8 +80,7 @@ By default, **singleton** is used.
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
featureAbility.startAbility({ featureAbility.startAbility({
want: want: {
{
action: "", action: "",
entities: [""], entities: [""],
type: "", type: "",
...@@ -83,13 +89,12 @@ By default, **singleton** is used. ...@@ -83,13 +89,12 @@ By default, **singleton** is used.
/* In the FA model, abilityName consists of package and ability name. */ /* In the FA model, abilityName consists of package and ability name. */
abilityName: "com.example.entry.secondAbility", abilityName: "com.example.entry.secondAbility",
uri: "" uri: ""
}, }
}, });
);
``` ```
### Starting a Remote Page Ability ### Starting a Remote Page Ability
>Note >NOTE
> >
>This feature applies only to system applications, since the **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications. >This feature applies only to system applications, since the **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications.
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
- [Video Playback Development](video-playback.md) - [Video Playback Development](video-playback.md)
- [Video Recording Development](video-recorder.md) - [Video Recording Development](video-recorder.md)
- Image - Image
- [Image Development](image.md) - [Image Development](image.md)
......
# Audio Capture Development # Audio Capture Development
## When to Use ## Introduction
You can use the APIs provided by **AudioCapturer** to record raw audio files. You can use the APIs provided by **AudioCapturer** to record raw audio files, thereby implementing audio data collection.
### State Check **Status check**: During application development, you are advised to use **on('stateChange')** to subscribe to state changes of the **AudioCapturer** instance. This is because some operations can be performed only when the audio capturer is in a given state. If the application performs an operation when the audio capturer is not in the given state, the system may throw an exception or generate other undefined behavior.
During application development, you are advised to use **on('stateChange')** to subscribe to state changes of the **AudioCapturer** instance. This is because some operations can be performed only when the audio capturer is in a given state. If the application performs an operation when the audio capturer is not in the given state, the system may throw an exception or generate other undefined behavior. ## Working Principles
For details about the APIs, see [AudioCapturer in Audio Management](../reference/apis/js-apis-audio.md#audiocapturer8). This following figure shows the audio capturer state transitions.
**Figure 1** Audio capturer state transitions
![audio-capturer-state](figures/audio-capturer-state.png)
- **PREPARED**: The audio capturer enters this state by calling **create()**.
- **RUNNING**: The audio capturer enters this state by calling **start()** when it is in the **PREPARED** state or by calling **start()** when it is in the **STOPPED** state.
- **STOPPED**: The audio capturer in the **RUNNING** state can call **stop()** to stop playing audio data.
- **RELEASED**: The audio capturer in the **PREPARED** or **STOPPED** state can use **release()** to release all occupied hardware and software resources. It will not transit to any other state after it enters the **RELEASED** state.
**Figure 1** Audio capturer state ## Constraints
![](figures/audio-capturer-state.png) Before developing the audio data collection feature, configure the **ohos.permission.MICROPHONE** permission for your application. For details about permission configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md).
## How to Develop ## How to Develop
For details about the APIs, see [AudioCapturer in Audio Management](../reference/apis/js-apis-audio.md#audiocapturer8).
1. Use **createAudioCapturer()** to create an **AudioCapturer** instance. 1. Use **createAudioCapturer()** to create an **AudioCapturer** instance.
Set parameters of the **AudioCapturer** instance in **audioCapturerOptions**. This instance is used to capture audio, control and obtain the recording status, and register a callback for notification. Set parameters of the **AudioCapturer** instance in **audioCapturerOptions**. This instance is used to capture audio, control and obtain the recording state, and register a callback for notification.
```js ```js
var audioStreamInfo = { import audio from '@ohos.multimedia.audio';
let audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_1, channels: audio.AudioChannel.CHANNEL_1,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
} }
var audioCapturerInfo = { let audioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC, source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 1 capturerFlags: 0 // 0 is the extended flag bit of the audio capturer. The default value is 0.
} }
var audioCapturerOptions = { let audioCapturerOptions = {
streamInfo: audioStreamInfo, streamInfo: audioStreamInfo,
capturerInfo: audioCapturerInfo capturerInfo: audioCapturerInfo
} }
let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions);
var state = audioRenderer.state; console.log('AudioRecLog: Create audio capturer success.');
```
2. (Optional) Use **on('stateChange')** to subscribe to audio renderer state changes.
If an application needs to perform some operations when the audio renderer state is updated, the application can subscribe to the state changes. For more events that can be subscribed to, see [Audio Management](../reference/apis/js-apis-audio.md).
```js
audioCapturer.on('stateChange',(state) => {
console.info('AudioCapturerLog: Changed State to : ' + state)
switch (state) {
case audio.AudioState.STATE_PREPARED:
console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------');
console.info('Audio State is : Prepared');
break;
case audio.AudioState.STATE_RUNNING:
console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------');
console.info('Audio State is : Running');
break;
case audio.AudioState.STATE_STOPPED:
console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------');
console.info('Audio State is : stopped');
break;
case audio.AudioState.STATE_RELEASED:
console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------');
console.info('Audio State is : released');
break;
default:
console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------');
console.info('Audio State is : invalid');
break;
}
});
``` ```
3. Use **start()** to start audio recording. 2. Use **start()** to start audio recording.
The capturer state will be **STATE_RUNNING** once the audio capturer is started. The application can then begin reading buffers. The capturer state will be **STATE_RUNNING** once the audio capturer is started. The application can then begin reading buffers.
```js ```js
import audio from '@ohos.multimedia.audio';
async function startCapturer() {
let state = audioCapturer.state;
// The audio capturer should be in the STATE_PREPARED, STATE_PAUSED, or STATE_STOPPED state after being started.
if (state != audio.AudioState.STATE_PREPARED || state != audio.AudioState.STATE_PAUSED ||
state != audio.AudioState.STATE_STOPPED) {
console.info('Capturer is not in a correct state to start');
return;
}
await audioCapturer.start(); await audioCapturer.start();
if (audioCapturer.state == audio.AudioState.STATE_RUNNING) {
let state = audioCapturer.state;
if (state == audio.AudioState.STATE_RUNNING) {
console.info('AudioRecLog: Capturer started'); console.info('AudioRecLog: Capturer started');
} else { } else {
console.info('AudioRecLog: Capturer start failed'); console.error('AudioRecLog: Capturer start failed');
}
} }
``` ```
4. Use **getBufferSize()** to obtain the minimum buffer size to read. 3. Read the captured audio data and convert it to a byte stream. Call **read()** repeatedly to read the data until the application stops the recording.
```js
var bufferSize = await audioCapturer.getBufferSize();
console.info('AudioRecLog: buffer size: ' + bufferSize);
```
5. Read the captured audio data and convert it to a byte stream. Call **read()** repeatedly to read the data until the application wants to stop the recording.
The following example shows how to write recorded data into a file. The following example shows how to write recorded data into a file.
```js ```js
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
const path = '/data/data/.pulse_dir/capture_js.wav'; let state = audioCapturer.state;
// The read operation can be performed only when the state is STATE_RUNNING.
if (state != audio.AudioState.STATE_RUNNING) {
console.info('Capturer is not in a correct state to read');
return;
}
const path = '/data/data/.pulse_dir/capture_js.wav'; // Path for storing the collected audio file.
let fd = fileio.openSync(path, 0o102, 0o777); let fd = fileio.openSync(path, 0o102, 0o777);
if (fd !== null) { if (fd !== null) {
console.info('AudioRecLog: file fd created'); console.info('AudioRecLog: file fd created');
...@@ -115,38 +110,140 @@ If an application needs to perform some operations when the audio renderer state ...@@ -115,38 +110,140 @@ If an application needs to perform some operations when the audio renderer state
console.info('AudioRecLog: file fd opened in append mode'); console.info('AudioRecLog: file fd opened in append mode');
} }
var numBuffersToCapture = 150; let numBuffersToCapture = 150; // Write data for 150 times.
while (numBuffersToCapture) { while (numBuffersToCapture) {
var buffer = await audioCapturer.read(bufferSize, true); let buffer = await audioCapturer.read(bufferSize, true);
if (typeof(buffer) == undefined) { if (typeof(buffer) == undefined) {
console.info('read buffer failed'); console.info('AudioRecLog: read buffer failed');
} else { } else {
var number = fileio.writeSync(fd, buffer); let number = fileio.writeSync(fd, buffer);
console.info('AudioRecLog: data written: ' + number); console.info(`AudioRecLog: data written: ${number}`);
} }
numBuffersToCapture--; numBuffersToCapture--;
} }
``` ```
6. Once the recording is complete, call **stop()** to stop the recording. 4. Once the recording is complete, call **stop()** to stop the recording.
```js
async function StopCapturer() {
let state = audioCapturer.state;
// The audio capturer can be stopped only when it is in STATE_RUNNING or STATE_PAUSED state.
if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) {
console.info('AudioRecLog: Capturer is not running or paused');
return;
}
```
await audioCapturer.stop(); await audioCapturer.stop();
if (audioCapturer.state == audio.AudioState.STATE_STOPPED) {
state = audioCapturer.state;
if (state == audio.AudioState.STATE_STOPPED) {
console.info('AudioRecLog: Capturer stopped'); console.info('AudioRecLog: Capturer stopped');
} else { } else {
console.info('AudioRecLog: Capturer stop failed'); console.error('AudioRecLog: Capturer stop failed');
}
} }
``` ```
7. After the task is complete, call **release()** to release related resources. 5. After the task is complete, call **release()** to release related resources.
```js ```js
async function releaseCapturer() {
let state = audioCapturer.state;
// The audio capturer can be released only when it is not in the STATE_RELEASED or STATE_NEW state.
if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) {
console.info('AudioRecLog: Capturer already released');
return;
}
await audioCapturer.release(); await audioCapturer.release();
if (audioCapturer.state == audio.AudioState.STATE_RELEASED) {
state = audioCapturer.state;
if (state == audio.AudioState.STATE_RELEASED) {
console.info('AudioRecLog: Capturer released'); console.info('AudioRecLog: Capturer released');
} else { } else {
console.info('AudioRecLog: Capturer release failed'); console.info('AudioRecLog: Capturer release failed');
} }
}
```
6. (Optional) Obtain the audio capturer information.
You can use the following code to obtain the audio capturer information:
```js
// Obtain the audio capturer state.
let state = audioCapturer.state;
// Obtain the audio capturer information.
let audioCapturerInfo : audio.AuduioCapturerInfo = await audioCapturer.getCapturerInfo();
// Obtain the audio stream information.
let audioStreamInfo : audio.AudioStreamInfo = await audioCapturer.getStreamInfo();
// Obtain the audio stream ID.
let audioStreamId : number = await audioCapturer.getAudioStreamId();
// Obtain the Unix timestamp, in nanoseconds.
let audioTime : number = await audioCapturer.getAudioTime();
// Obtain a proper minimum buffer size.
let bufferSize : number = await audioCapturer.getBuffersize();
```
7. (Optional) Use **on('markReach')** to subscribe to the mark reached event, and use **off('markReach')** to unsubscribe from the event.
After the mark reached event is subscribed to, when the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned.
```js
audioCapturer.on('markReach', (reachNumber) => {
console.info('Mark reach event Received');
console.info(`The Capturer reached frame: ${reachNumber}`);
});
audioCapturer.off('markReach'); // Unsubscribe from the mark reached event. This event will no longer be listened for.
```
8. (Optional) Use **on('periodReach')** to subscribe to the period reached event, and use **off('periodReach')** to unsubscribe from the event.
After the period reached event is subscribed to, each time the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned.
```js
audioCapturer.on('periodReach', (reachNumber) => {
console.info('Period reach event Received');
console.info(`In this period, the Capturer reached frame: ${reachNumber}`);
});
audioCapturer.off('periodReach'); // Unsubscribe from the period reached event. This event will no longer be listened for.
```
9. If your application needs to perform some operations when the audio capturer state is updated, it can subscribe to the state change event. When the audio capturer state is updated, the application receives a callback containing the event type.
```js
audioCapturer.on('stateChange', (state) => {
console.info(`AudioCapturerLog: Changed State to : ${state}`)
switch (state) {
case audio.AudioState.STATE_PREPARED:
console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------');
console.info('Audio State is : Prepared');
break;
case audio.AudioState.STATE_RUNNING:
console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------');
console.info('Audio State is : Running');
break;
case audio.AudioState.STATE_STOPPED:
console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------');
console.info('Audio State is : stopped');
break;
case audio.AudioState.STATE_RELEASED:
console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------');
console.info('Audio State is : released');
break;
default:
console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------');
console.info('Audio State is : invalid');
break;
}
});
``` ```
# Audio Interruption Mode Development # Audio Interruption Mode Development
## When to Use ## Introduction
The audio interruption mode is used to control the playback of multiple audio streams.<br> The audio interruption mode is used to control the playback of multiple audio streams.
Audio applications can set the audio interruption mode to independent or shared under **AudioRenderer**.<br>
In shared mode, multiple audio streams share one session ID. In independent mode, each audio stream has an independent session ID. Audio applications can set the audio interruption mode to independent or shared under **AudioRenderer**.
### Asynchronous Operations In shared mode, multiple audio streams share one session ID. In independent mode, each audio stream has an independent session ID.
To prevent the UI thread from being blocked, most **AudioRenderer** calls are asynchronous. Each API provides the callback and promise functions. The following examples use the promise functions. **Asynchronous operation**: To prevent the UI thread from being blocked, most **AudioRenderer** calls are asynchronous. Each API provides the callback and promise functions. The following examples use the promise functions.
## How to Develop ## How to Develop
For details about the APIs, see [AudioRenderer in Audio Management](../reference/apis/js-apis-audio.md#audiorenderer8). For details about the APIs, see [AudioRenderer in Audio Management](../reference/apis/js-apis-audio.md#audiorenderer8).
1. Use **createAudioRenderer()** to create an **AudioRenderer** instance.
1. Use **createAudioRenderer()** to create an **AudioRenderer** instance.<br> Set parameters of the **AudioRenderer** instance in **audioRendererOptions**.
Set parameters of the **AudioRenderer** instance in **audioRendererOptions**.<br>
This instance is used to render audio, control and obtain the rendering status, and register a callback for notification.<br>
```js This instance is used to render audio, control and obtain the rendering status, and register a callback for notification.
```js
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
var audioStreamInfo = { var audioStreamInfo = {
...@@ -39,7 +40,7 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference ...@@ -39,7 +40,7 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
rendererInfo: audioRendererInfo rendererInfo: audioRendererInfo
} }
let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
``` ```
2. Set the audio interruption mode. 2. Set the audio interruption mode.
......
# Audio Stream Management Development # Audio Stream Management Development
## When to Use ## Introduction
You can use **AudioStreamManager** to manage audio streams. You can use **AudioStreamManager** to manage audio streams.
### Development Process ## Working Principles
During application development, use **getStreamManager()** to create an **AudioStreamManager** instance. Then, you can call **on('audioRendererChange')** or **on('audioCapturerChange')** to listen for status, client, and audio attribute changes of the audio playback or recording application. To cancel the listening for these changes, call **off('audioRendererChange')** or **off('audioCapturerChange')**. You can call **getCurrentAudioRendererInfoArray()** to obtain information about the audio playback application, such as the unique audio stream ID, UID of the audio playback client, and audio status. Similarly, you can call **getCurrentAudioCapturerInfoArray()** to obtain information about the audio recording application. The figure below shows the invoking relationship. The following figure shows the calling relationship of **AudioStreamManager** APIs.
For details about the APIs, see [AudioStreamManager](../reference/apis/js-apis-audio.md#audiostreammanager9). **Figure 1** AudioStreamManager API calling relationship
**Figure 1** Audio stream management invoking relationship ![en-us_image_audio_stream_manager](figures/en-us_image_audio_stream_manager.png)
![](figures/en-us_image_audio_stream_manager.png) **NOTE**: During application development, use **getStreamManager()** to create an **AudioStreamManager** instance. Then, you can call **on('audioRendererChange')** or **on('audioCapturerChange')** to listen for status, client, and audio attribute changes of the audio playback or recording application. To cancel the listening for these changes, call **off('audioRendererChange')** or **off('audioCapturerChange')**. You can call **getCurrentAudioRendererInfoArray()** to obtain information about the audio playback application, such as the unique audio stream ID, UID of the audio playback client, and audio status. Similarly, you can call **getCurrentAudioCapturerInfoArray()** to obtain information about the audio recording application.
## How to Develop ## How to Develop
For details about the APIs, see [AudioStreamManager](../reference/apis/js-apis-audio.md#audiostreammanager9).
1. Create an **AudioStreamManager** instance. 1. Create an **AudioStreamManager** instance.
Before using **AudioStreamManager** APIs, you must use **getStreamManager()** to create an **AudioStreamManager** instance. Before using **AudioStreamManager** APIs, you must use **getStreamManager()** to create an **AudioStreamManager** instance.
```js ```js
var audioStreamManager = audio.getStreamManager(); var audioManager = audio.getAudioManager();
var audioStreamManager = audioManager.getStreamManager();
``` ```
2. (Optional) Call **on('audioRendererChange')** to listen for audio renderer changes. 2. (Optional) Call **on('audioRendererChange')** to listen for audio renderer changes.
If an application needs to receive notifications when the audio playback application status, audio playback client, or audio attribute changes, it can subscribe to this event. For more events that can be subscribed to, see [Audio Management](../reference/apis/js-apis-audio.md).
If an application needs to receive notifications when the audio playback application status, audio playback client, or audio attribute changes, it can subscribe to this event. For more events that can be subscribed to, see [Audio Management](../reference/apis/js-apis-audio.md).
```js ```js
audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => {
...@@ -61,7 +65,8 @@ If an application needs to receive notifications when the audio playback applica ...@@ -61,7 +65,8 @@ If an application needs to receive notifications when the audio playback applica
``` ```
4. (Optional) Call **on('audioCapturerChange')** to listen for audio capturer changes. 4. (Optional) Call **on('audioCapturerChange')** to listen for audio capturer changes.
If an application needs to receive notifications when the audio recording application status, audio recording client, or audio attribute changes, it can subscribe to this event. For more events that can be subscribed to, see [Audio Management](../reference/apis/js-apis-audio.md).
If an application needs to receive notifications when the audio recording application status, audio recording client, or audio attribute changes, it can subscribe to this event. For more events that can be subscribed to, see [Audio Management](../reference/apis/js-apis-audio.md).
```js ```js
audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => {
...@@ -94,7 +99,8 @@ If an application needs to receive notifications when the audio recording applic ...@@ -94,7 +99,8 @@ If an application needs to receive notifications when the audio recording applic
``` ```
6. (Optional) Call **getCurrentAudioRendererInfoArray()** to obtain information about the current audio renderer. 6. (Optional) Call **getCurrentAudioRendererInfoArray()** to obtain information about the current audio renderer.
This API can be used to obtain the unique ID of the audio stream, UID of the audio playback client, audio status, and other information about the audio player. Before calling this API, a third-party application must have the **ohos.permission.USE_BLUETOOTH** permission configured, for the device name and device address to be displayed correctly.
This API can be used to obtain the unique ID of the audio stream, UID of the audio playback client, audio status, and other information about the audio player. Before calling this API, a third-party application must have the **ohos.permission.USE_BLUETOOTH** permission configured, for the device name and device address to be displayed correctly.
```js ```js
await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) {
...@@ -127,7 +133,7 @@ This API can be used to obtain the unique ID of the audio stream, UID of the aud ...@@ -127,7 +133,7 @@ This API can be used to obtain the unique ID of the audio stream, UID of the aud
``` ```
7. (Optional) Call **getCurrentAudioCapturerInfoArray()** to obtain information about the current audio capturer. 7. (Optional) Call **getCurrentAudioCapturerInfoArray()** to obtain information about the current audio capturer.
This API can be used to obtain the unique ID of the audio stream, UID of the audio recording client, audio status, and other information about the audio capturer. Before calling this API, a third-party application must have the **ohos.permission.USE_BLUETOOTH** permission configured, for the device name and device address to be displayed correctly. This API can be used to obtain the unique ID of the audio stream, UID of the audio recording client, audio status, and other information about the audio capturer. Before calling this API, a third-party application must have the **ohos.permission.USE_BLUETOOTH** permission configured, for the device name and device address to be displayed correctly.
```js ```js
await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) {
......
# OpenSL ES Audio Recording Development # OpenSL ES Audio Recording Development
## When to Use ## Introduction
You can use OpenSL ES to develop the audio recording function in OpenHarmony. Currently, only some [OpenSL ES APIs](https://gitee.com/openharmony/third_party_opensles/blob/master/api/1.0.1/OpenSLES.h) are implemented. If an API that has not been implemented is called, **SL_RESULT_FEATURE_UNSUPPORTED** will be returned. You can use OpenSL ES to develop the audio recording function in OpenHarmony. Currently, only some [OpenSL ES APIs](https://gitee.com/openharmony/third_party_opensles/blob/master/api/1.0.1/OpenSLES.h) are implemented. If an API that has not been implemented is called, **SL_RESULT_FEATURE_UNSUPPORTED** will be returned.
......
# OpenSL ES Audio Playback Development # OpenSL ES Audio Playback Development
## When to Use ## Introduction
You can use OpenSL ES to develop the audio playback function in OpenHarmony. Currently, only some [OpenSL ES APIs](https://gitee.com/openharmony/third_party_opensles/blob/master/api/1.0.1/OpenSLES.h) are implemented. If an API that has not been implemented is called, **SL_RESULT_FEATURE_UNSUPPORTED** will be returned. You can use OpenSL ES to develop the audio playback function in OpenHarmony. Currently, only some [OpenSL ES APIs](https://gitee.com/openharmony/third_party_opensles/blob/master/api/1.0.1/OpenSLES.h) are implemented. If an API that has not been implemented is called, **SL_RESULT_FEATURE_UNSUPPORTED** will be returned.
...@@ -58,7 +58,7 @@ To use OpenSL ES to develop the audio playback function in OpenHarmony, perform ...@@ -58,7 +58,7 @@ To use OpenSL ES to develop the audio playback function in OpenHarmony, perform
5. Obtain the **bufferQueueItf** instance of the **SL_IID_OH_BUFFERQUEUE** interface. 5. Obtain the **bufferQueueItf** instance of the **SL_IID_OH_BUFFERQUEUE** interface.
``` ```c++
SLOHBufferQueueItf bufferQueueItf; SLOHBufferQueueItf bufferQueueItf;
(*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_OH_BUFFERQUEUE, &bufferQueueItf); (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_OH_BUFFERQUEUE, &bufferQueueItf);
``` ```
......
...@@ -4,6 +4,4 @@ ...@@ -4,6 +4,4 @@
- [Drawing Development](drawing-guidelines.md) - [Drawing Development](drawing-guidelines.md)
- [Raw File Development](rawfile-guidelines.md) - [Raw File Development](rawfile-guidelines.md)
- [Native Window Development](native-window-guidelines.md) - [Native Window Development](native-window-guidelines.md)
- [Using MindSpore Lite for Model Inference](native-window-guidelines.md) - [Using MindSpore Lite for Model Inference](mindspore-lite-guidelines.md)
...@@ -125,6 +125,8 @@ ...@@ -125,6 +125,8 @@
- Security - Security
- [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md) - [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md)
- [@ohos.privacyManager](js-apis-privacyManager.md) - [@ohos.privacyManager](js-apis-privacyManager.md)
- [@ohos.security.cert](js-apis-cert.md)
- [@ohos.security.cryptoFramework]js-apis-cryptoFramework.md)
- [@ohos.security.huks ](js-apis-huks.md) - [@ohos.security.huks ](js-apis-huks.md)
- [@ohos.userIAM.faceAuth](js-apis-useriam-faceauth.md) - [@ohos.userIAM.faceAuth](js-apis-useriam-faceauth.md)
- [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md) - [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md)
...@@ -146,6 +148,8 @@ ...@@ -146,6 +148,8 @@
- [@ohos.document](js-apis-document.md) - [@ohos.document](js-apis-document.md)
- [@ohos.environment](js-apis-environment.md) - [@ohos.environment](js-apis-environment.md)
- [@ohos.data.fileAccess](js-apis-fileAccess.md)
- [@ohos.fileExtensionInfo](js-apis-fileExtensionInfo.md)
- [@ohos.fileio](js-apis-fileio.md) - [@ohos.fileio](js-apis-fileio.md)
- [@ohos.filemanagement.userfile_manager](js-apis-userfilemanager.md) - [@ohos.filemanagement.userfile_manager](js-apis-userfilemanager.md)
- [@ohos.multimedia.medialibrary](js-apis-medialibrary.md) - [@ohos.multimedia.medialibrary](js-apis-medialibrary.md)
......
...@@ -24,7 +24,9 @@ SystemCapability.BundleManager.DistributedBundleFramework ...@@ -24,7 +24,9 @@ SystemCapability.BundleManager.DistributedBundleFramework
For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels). For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels).
## distributedBundle.getRemoteAbilityInfo ## distributedBundle.getRemoteAbilityInfo<sup>deprecated<sup>
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo](js-apis-distributedBundle.md) instead.
getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback&lt;RemoteAbilityInfo&gt;): void; getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback&lt;RemoteAbilityInfo&gt;): void;
...@@ -51,7 +53,9 @@ This is a system API and cannot be called by third-party applications. ...@@ -51,7 +53,9 @@ This is a system API and cannot be called by third-party applications.
## distributedBundle.getRemoteAbilityInfo ## distributedBundle.getRemoteAbilityInfo<sup>deprecated<sup>
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo](js-apis-distributedBundle.md) instead.
getRemoteAbilityInfo(elementName: ElementName): Promise&lt;RemoteAbilityInfo&gt; getRemoteAbilityInfo(elementName: ElementName): Promise&lt;RemoteAbilityInfo&gt;
...@@ -81,7 +85,9 @@ This is a system API and cannot be called by third-party applications. ...@@ -81,7 +85,9 @@ This is a system API and cannot be called by third-party applications.
| ------------------------------------------------------------ | --------------------------------- | | ------------------------------------------------------------ | --------------------------------- |
| Promise\<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | Promise used to return the remote ability information.| | Promise\<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | Promise used to return the remote ability information.|
## distributedBundle.getRemoteAbilityInfos ## distributedBundle.getRemoteAbilityInfos<sup>deprecated<sup>
> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo](js-apis-distributedBundle.md) instead.
getRemoteAbilityInfos(elementNames: Array&lt;ElementName&gt;, callback: AsyncCallback&lt;Array&lt;RemoteAbilityInfo&gt;&gt;): void; getRemoteAbilityInfos(elementNames: Array&lt;ElementName&gt;, callback: AsyncCallback&lt;Array&lt;RemoteAbilityInfo&gt;&gt;): void;
...@@ -104,11 +110,13 @@ This is a system API and cannot be called by third-party applications. ...@@ -104,11 +110,13 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | | ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | Yes | **ElementName** array, whose maximum length is 10. | | elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | Yes | **ElementName** array, whose maximum length is 10. |
| callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | Yes | Callback used to return an array of the remote ability information.| | callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | Yes | Callback used to return the remote ability information.|
## distributedBundle.getRemoteAbilityInfos<sup>deprecated<sup>
## distributedBundle.getRemoteAbilityInfos > This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo](js-apis-distributedBundle.md) instead.
getRemoteAbilityInfos(elementNames: Array&lt;ElementName&gt;): Promise&lt;Array&lt;RemoteAbilityInfo&gt;&gt; getRemoteAbilityInfos(elementNames: Array&lt;ElementName&gt;): Promise&lt;Array&lt;RemoteAbilityInfo&gt;&gt;
......
# ShortcutInfo # ShortcutInfo<sup>(deprecated)<sup>
The **ShortcutInfo** module provides shortcut information defined in the configuration file. For details about the configuration in the FA model, see [config.json](../../quick-start/package-structure.md). For details about the configuration in the stage model, see [Internal Structure of the shortcuts Attribute](../../quick-start/stage-structure.md#internal-structure-of-the-shortcuts-attribute). The **ShortcutInfo** module provides shortcut information defined in the configuration file. For details about the configuration in the FA model, see [config.json](../../quick-start/package-structure.md). For details about the configuration in the stage model, see [Internal Structure of the shortcuts Attribute](../../quick-start/stage-structure.md#internal-structure-of-the-shortcuts-attribute).
> **NOTE** > **NOTE**
> >
> This module is deprecated since API version 9. You are advised to use [ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) instead.
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## ShortcutWant ## ShortcutWant<sup>(deprecated)<sup>
Describes the information about the target to which the shortcut points. > This API is deprecated since API version 9. You are advised to use [ShortcutWant](js-apis-bundleManager-shortcutInfo.md) instead.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------------------------- | ------ | ---- | ---- | -------------------- | | ------------------------- | ------ | ---- | ---- | -------------------- |
| targetBundle | string | Yes | No | Target bundle of the shortcut.| | targetBundle | string | Yes | No | Target bundle of the shortcut.|
| targetModule<sup>9+</sup> | string | Yes | No | Target module of the shortcut. |
| targetClass | string | Yes | No | Target class required by the shortcut.| | targetClass | string | Yes | No | Target class required by the shortcut.|
## ShortcutInfo ## ShortcutInfo<sup>(deprecated)<sup>
> This API is deprecated since API version 9. You are advised to use [ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) instead.
Describes the shortcut attribute information.
**System capability**: SystemCapability.BundleManager.BundleFramework **System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ----------------------- | ------------------------------------------ | ---- | ---- | ---------------------------- | | ----------------------- | ------------------------------------------ | ---- | ---- | ---------------------------- |
...@@ -40,4 +42,3 @@ Describes the shortcut attribute information. ...@@ -40,4 +42,3 @@ Describes the shortcut attribute information.
| isStatic | boolean | Yes | No | Whether the shortcut is static. | | isStatic | boolean | Yes | No | Whether the shortcut is static. |
| isHomeShortcut | boolean | Yes | No | Whether the shortcut is a home shortcut.| | isHomeShortcut | boolean | Yes | No | Whether the shortcut is a home shortcut.|
| isEnabled | boolean | Yes | No | Whether the shortcut is enabled. | | isEnabled | boolean | Yes | No | Whether the shortcut is enabled. |
| moduleName<sup>9+</sup> | string | Yes | No | Module name of the shortcut. |
...@@ -6,7 +6,9 @@ The **RemoteAbilityInfo** module provides information about a remote ability. ...@@ -6,7 +6,9 @@ The **RemoteAbilityInfo** module provides information about a remote ability.
> >
> 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. > 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.
## RemoteAbilityInfo ## RemoteAbilityInfo<sup>(deprecated)<sup>
> This API is deprecated since API version 9. You are advised to use [RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md) instead.
**System capability**: SystemCapability.BundleManager.DistributedBundleFramework **System capability**: SystemCapability.BundleManager.DistributedBundleFramework
......
# ElementName
The **ElementName** module provides the element name information, which can be obtained through [Context.getElementName](js-apis-Context.md).
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## ElementName
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
| Name | Type | Readable| Writable| Description |
| ----------------------- | ---------| ---- | ---- | ------------------------- |
| deviceId | string | Yes | Yes | Device ID. |
| bundleName | string | Yes | Yes | Bundle name of the application. |
| abilityName | string | Yes | Yes | Name of the ability. |
| uri | string | Yes | Yes | Resource ID. |
| shortName | string | Yes | Yes | Short name of the ability. |
| moduleName | string | Yes | Yes | Module name of the HAP file to which the ability belongs. |
# RemoteAbilityInfo
The **RemoteAbilityInfo** module provides information about a remote ability, which can be obtained through [distributedBundle.getRemoteAbilityInfo](js-apis-distributedBundle.md).
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## RemoteAbilityInfo
**System capability**: SystemCapability.BundleManager.DistributedBundleFramework
**System API**: This is a system API.
| Name | Type | Readable| Writable| Description |
| ----------- | -------------------------------------------- | ---- | ---- | ----------------------- |
| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | No | Element name information of the remote ability. |
| label | string | Yes | No | Label of the remote ability. |
| icon | string | Yes | No | Icon of the remote ability.|
# ShortcutInfo
The **ShortcutInfo** module provides shortcut information defined in the configuration file. For details about the configuration in the FA model, see [config.json](../../quick-start/package-structure.md). For details about the configuration in the stage model, see [Internal Structure of the shortcuts Attribute](../../quick-start/stage-structure.md#internal-structure-of-the-shortcuts-attribute).
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## ShortcutWant
**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher
**System API**: This is a system API.
| Name | Type | Readable| Writable| Description |
| ------------------------- | ------ | ---- | ---- | -------------------- |
| targetBundle | string | Yes | No | Target bundle name of the shortcut.|
| targetModule | string | Yes | No | Target module name of the shortcut. |
| targetAbility | string | Yes | No | Target ability name of the shortcut.|
## ShortcutInfo
**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher
**System API**: This is a system API.
| Name | Type | Readable| Writable| Description |
| ----------------------- | ------------------------------------------ | ---- | ---- | ---------------------------- |
| id | string | Yes | No | ID of the application to which the shortcut belongs. |
| bundleName | string | Yes | No | Name of the bundle that contains the shortcut. |
| moduleName | string | Yes | No | Module name of the shortcut. |
| hostAbility | string | Yes | No | Local ability name of the shortcut. |
| icon | string | Yes | No | Icon of the shortcut. |
| iconId | number | Yes | No | Icon ID of the shortcut. |
| label | string | Yes | No | Label of the shortcut. |
| labelId | number | Yes | No | Label ID of the shortcut. |
| wants | Array\<[ShortcutWant](#shortcutwant)> | Yes | No | Want information required for the shortcut. |
此差异已折叠。
...@@ -39,10 +39,12 @@ Defines the data structure of the fault log information. ...@@ -39,10 +39,12 @@ Defines the data structure of the fault log information.
| summary | string | Summary of the fault.| | summary | string | Summary of the fault.|
| fullLog | string | Full log text.| | fullLog | string | Full log text.|
## faultLogger.querySelfFaultLog ## faultLogger.querySelfFaultLog<sup>(deprecated)</sup>
querySelfFaultLog(faultType: FaultType, callback: AsyncCallback&lt;Array&lt;FaultLogInfo&gt;&gt;) : void querySelfFaultLog(faultType: FaultType, callback: AsyncCallback&lt;Array&lt;FaultLogInfo&gt;&gt;) : void
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [faultLogger.query](#faultloggerquery9) instead.
Obtains the fault information about the current process. This API uses an asynchronous callback to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. Obtains the fault information about the current process. This API uses an asynchronous callback to return the fault information array obtained, which contains a maximum of 10 pieces of fault information.
**System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger **System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger
...@@ -52,7 +54,8 @@ Obtains the fault information about the current process. This API uses an asynch ...@@ -52,7 +54,8 @@ Obtains the fault information about the current process. This API uses an asynch
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| faultType | [FaultType](#faulttype) | Yes| Fault type.| | faultType | [FaultType](#faulttype) | Yes| Fault type.|
| callback | AsyncCallbackArray&lt;Array&lt;[FaultLogInfo](#faultloginfo)>> | Yes | Callback used to return the fault information array.<br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned. | | callback | AsyncCallbackArray&lt;Array&lt;[FaultLogInfo](#faultloginfo)&gt;&gt; | Yes| Callback used to return the fault information array.<br>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned.
**Example** **Example**
```js ```js
...@@ -78,10 +81,12 @@ function queryFaultLogCallback(error, value) { ...@@ -78,10 +81,12 @@ function queryFaultLogCallback(error, value) {
faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH, queryFaultLogCallback); faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH, queryFaultLogCallback);
``` ```
## faultLogger.querySelfFaultLog ## faultLogger.querySelfFaultLog<sup>(deprecated)</sup>
querySelfFaultLog(faultType: FaultType) : Promise&lt;Array&lt;FaultLogInfo&gt;&gt; querySelfFaultLog(faultType: FaultType) : Promise&lt;Array&lt;FaultLogInfo&gt;&gt;
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [faultLogger.query](#faultloggerquery9-1) instead.
Obtains the fault information about the current process. This API uses a promise to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. Obtains the fault information about the current process. This API uses a promise to return the fault information array obtained, which contains a maximum of 10 pieces of fault information.
**System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger **System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger
...@@ -120,3 +125,110 @@ async function getLog() { ...@@ -120,3 +125,110 @@ async function getLog() {
} }
} }
``` ```
## faultLogger.query<sup>9+</sup>
query(faultType: FaultType, callback: AsyncCallback&lt;Array&lt;FaultLogInfo&gt;&gt;) : void
Obtains the fault information about the current process. This API uses an asynchronous callback to return the fault information array obtained, which contains a maximum of 10 pieces of fault information.
**System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| faultType | [FaultType](#faulttype) | Yes| Fault type.|
| callback | AsyncCallbackArray&lt;Array&lt;[FaultLogInfo](#faultloginfo)&gt;&gt; | Yes| Callback used to return the fault information array.<br>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned.
**Error codes**
For details about the error codes, see [faultLogger Error Codes](../errorcodes/errorcode-faultlogger.md).
| ID| Error Message|
| --- | --- |
| 10600001 | The service is not running or broken |
**Example**
```js
function queryFaultLogCallback(error, value) {
if (error) {
console.info('error is ' + error);
} else {
console.info("value length is " + value.length);
let len = value.length;
for (let i = 0; i < len; i++) {
console.info("log: " + i);
console.info("Log pid: " + value[i].pid);
console.info("Log uid: " + value[i].uid);
console.info("Log type: " + value[i].type);
console.info("Log timestamp: " + value[i].timestamp);
console.info("Log reason: " + value[i].reason);
console.info("Log module: " + value[i].module);
console.info("Log summary: " + value[i].summary);
console.info("Log text: " + value[i].fullLog);
}
}
}
try {
faultLogger.query(faultLogger.FaultType.JS_CRASH, queryFaultLogCallback);
} catch (err) {
console.error(`code: ${err.code}, message: ${err.message}`);
}
```
## faultLogger.query<sup>9+</sup>
query(faultType: FaultType) : Promise&lt;Array&lt;FaultLogInfo&gt;&gt;
Obtains the fault information about the current process. This API uses a promise to return the fault information array obtained, which contains a maximum of 10 pieces of fault information.
**System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| faultType | [FaultType](#faulttype) | Yes| Fault type.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Array&lt;[FaultLogInfo](#faultloginfo)&gt;&gt; | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**.<br>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.|
**Error codes**
For details about the error codes, see [faultLogger Error Codes](../errorcodes/errorcode-faultlogger.md).
| ID| Error Message|
| --- | --- |
| 10600001 | The service is not running or broken |
**Example**
```js
async function getLog() {
try {
let value = await faultLogger.query(faultLogger.FaultType.JS_CRASH);
if (value) {
console.info("value length is " + value.length);
let len = value.length;
for (let i = 0; i < len; i++) {
console.info("log: " + i);
console.info("Log pid: " + value[i].pid);
console.info("Log uid: " + value[i].uid);
console.info("Log type: " + value[i].type);
console.info("Log timestamp: " + value[i].timestamp);
console.info("Log reason: " + value[i].reason);
console.info("Log module: " + value[i].module);
console.info("Log summary: " + value[i].summary);
console.info("Log text: " + value[i].fullLog);
}
}
} catch (err) {
console.error(`code: ${err.code}, message: ${err.message}`);
}
}
```
此差异已折叠。
# User File Extension Info
The **fileExtensionInfo** module defines attributes in **RootInfo** and **FileInfo** of the user file access and management module.
>**NOTE**
>
>- The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>- The APIs provided by this module are system APIs.
## Modules to Import
```js
import fileExtensionInfo from '@ohos.fileExtensionInfo';
```
## fileExtensionInfo.DeviceType
Defines the values of **deviceType** used in **RootInfo**.
**System capability**: SystemCapability.FileManagement.UserFileService
| Name| Value| Description|
| ----- | ------ | ------ |
| DEVICE_LOCAL_DISK | 1 | Local disk.|
| DEVICE_SHARED_DISK | 2 | Shared disk.|
| DEVICE_SHARED_TERMINAL | 3 | Distributed network device.|
| DEVICE_NETWORK_NEIGHBORHOODS | 4 | Network neighbor device.|
| DEVICE_EXTERNAL_MTP | 5 | MTP device.|
| DEVICE_EXTERNAL_USB | 6 | USB device.|
| DEVICE_EXTERNAL_CLOUD | 7 | Cloud disk.|
## fileExtensionInfo.DeviceFlag
Defines the values of **deviceFlags** used in **RootInfo**. **deviceFlags** is used to determine whether a capability is available through the AND operation.
**System capability**: SystemCapability.FileManagement.UserFileService
### Attributes
| Name| Type | Value| Readable| Writable| Description |
| ------ | ------ | ---- | ---- | ---- | -------- |
| SUPPORTS_READ | number | 0b1 | Yes | No | Read support.|
| SUPPORTS_WRITE | number | 0b10 | Yes | No | Write support.|
## fileExtensionInfo.DocumentFlag
Defines the values of **mode** used in **FileInfo**.
**System capability**: SystemCapability.FileManagement.UserFileService
### Attributes
| Name| Type | Value| Readable| Writable| Description |
| ------ | ------ | ---- | ---- | ---- | -------- |
| REPRESENTS_FILE | number | 0b1 | Yes | No | File.|
| REPRESENTS_DIR | number | 0b10 | Yes | No | Directory.|
| SUPPORTS_READ | number | 0b100 | Yes | No | Read support.|
| SUPPORTS_WRITE | number | 0b1000 | Yes | No | Write support.|
# UI Appearance
The **uiAppearance** module provides basic capabilities for managing the system appearance. It allows for color mode configuration currently, and will introduce more features over time.
> **NOTE**
>
> The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import
```ts
import uiAppearance from '@ohos.uiAppearance'
```
## DarkMode
Enumerates the color modes.
**System capability**: SystemCapability.ArkUI.UiAppearance
| Name| Value| Description|
| -- | -- | -- |
| ALWAYS_DARK | 0 | The system is always in dark mode. |
| ALWAYS_LIGHT | 1 | The system is always in light mode.|
## uiAppearance.setDarkMode
setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void
Sets the system color mode. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.ArkUI.UiAppearance
**Parameters**
| Name| Type| Mandatory| Description|
| -- | -- | -- | -- |
| mode | [DarkMode](#darkmode) | Yes| Color mode to set.|
| callback | AsyncCallback\<void>| Yes| Callback used to return the result.|
**Example**
```ts
uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK, (err) => {
console.info(`${err}`);
})
```
## uiAppearance.setDarkMode
setDarkMode(mode: DarkMode): Promise\<void>;
Sets the system color mode. This API uses a promise to return the result.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.ArkUI.UiAppearance
**Parameters**
| Name| Type| Mandatory| Description|
| -- | -- | -- | -- |
| mode | [DarkMode](#darkmode) | Yes| Color mode to set.|
**Return value**
| Type | Description |
| ------ | ------------------------------ |
| Promise\<void> | Promise that returns no value.|
**Example**
```ts
uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK).then(() => {
console.log('Set dark-mode successfully.');
}).catch((err) => {
console.log(`Set dark-mode failed, ${err}`);
});
```
## uiAppearance.getDarkMode
getDarkMode(): DarkMode;
Obtains the system color mode.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.ArkUI.UiAppearance
**Return value**
| Type| Description|
| -- | -- |
|[DarkMode](#darkmode) | Color mode obtained.|
**Example**
```ts
let darkMode = uiAppearance.getDarkMode();
console.log(`Get dark-mode ${darkMode}`);
```
# Bundle Error Codes
## 17700001 Nonexistent Bundle Name
**Error Message**
The specified bundle name is not found.
**Description**
This error code is reported when the bundle name passed in the API does not exist.
**Possible Causes**
1. The bundle name is misspelled.
2. The corresponding application is not installed.
**Solution**
1. Check whether the spelling of the bundle name is correct.
2. Check whether the corresponding application is installed.
## 17700002 Nonexistent Module Name
**Error Message**
The specified module name is not found.
**Description**
This error code is reported when the module name passed in the API does not exist.
**Possible Causes**
1. The module name is misspelled.
2. The module is not installed for the application.
**Solution**
1. Check whether the spelling of the module name is correct.
2. Check whether the module is installed for the application.
## 17700003 Nonexistent Ability Name
**Error Message**
The specified ability name is not found.
**Description**
This error code is reported when the ability name passed in the API does not exist.
**Possible Causes**
1. The ability name is misspelled.
2. The corresponding application is not installed.
**Solution**
1. Check whether the spelling of the ability name is correct.
2. Check whether the ability is installed for the application.
## 17700004 Nonexistent User ID
**Error Message**
The specified user id is not found.
**Description**
This error code is reported when the user ID passed in the API does not exist.
**Possible Causes**
The user ID is incorrect. The user does not exist.
**Solution**
1. Check whether the user ID is correct.
2. Check whether the user exists.
## 17700005 Nonexistent Application ID
**Error Message**
The specified appId is not found.
**Description**
This error code is reported when the value of **appId** passed in the API is an empty string.
**Possible Causes**
**appId** is an empty string.
**Solution**
Check whether **appId** is an empty string.
## 17700006 Nonexistent Permission
**Error Message**
The specified permission is not found.
**Description**
This error code is reported when the permission passed in the API does not exist.
**Possible Causes**
1. The permission name is misspelled.
2. The permission does not exist.
**Solution**
1. Check whether the spelling of the permission name is correct.
2. Check whether the permission exists.
## 17700007 Incorrect Device ID
**Error Message**
The specified deviceId is not found.
**Description**
This error code is reported when the device ID passed in the API is incorrect.
**Possible Causes**
1. The device ID is incorrect.
2. The device ID does not exist.
**Solution**
1. Check whether the device ID is correct.
2. Check whether the device ID exists.
## 17700010 Application Installation Failure Due to File Parsing Failure
**Error Message**
Failed to install the hap since the hap fails to be parsed.
**Description**
This error code is reported when the application fails to be installed because the HAP fails to be parsed.
**Possible Causes**
1. The HAP is not in ZIP format.
2. The configuration file in the HAP is not in JSON format.
3. Necessary fields are missing in the configuration file.
**Solution**
1. Check whether the HAP is in ZIP format.
2. Check whether the configuration file is in [JSON format](../../quick-start/stage-structure.md).
3. Check whether an error message is displayed when DevEco Studio compiles the HAP. If necessary fields are missing, an error message will be displayed.
## 17700011 Application Installation Failure Due to Signature Verification Failure
**Error Message**
Failed to install the hap since the hap signature fails to be verified.
**Description**
This error code is reported when the application fails to be installed due to signature verification failure.
**Possible Causes**
1. The HAP is not signed.
2. The source of the HAP signature information is unreliable.
3. The signature information of the HAP used for an upgrade is different from that of the installed HAP.
4. The signature information of multiple HAPs is inconsistent.
**Solution**
1. Check whether the HAP is signed.
2. Check whether the same certificate is used for signing multiple HAPs.
3. Check whether the certificate used for signing the upgrade HAP is the same as the certificate used for signing the installed HAP.
## 17700012 Application Installation Failure Due to Invalid File Path or Too Large File
**Error Message**
Failed to install the hap since the path of the hap is invalid or too large size.
**Description**
This error code is reported when the application fails to be installed because the HAP path is invalid or the HAP is too large.
**Possible Causes**
1. The path of the HAP does not exist.
2. The path of the HAP is inaccessible.
3. The size of the HAP exceeds the upper limit 4 GB.
**Solution**
1. Check whether the HAP path exists.
2. Check whether the HAP is read only or executable.
3. Check whether the size of the HAP exceeds 4 GB.
## 17700015 Application Installation Failure Due to Different Configuration Information of Multiple HAP Packages
**Error Message**
Failed to install haps since the configuration information of multi haps is inconsistent.
**Description**
This error code is reported when the application fails to be installed because the HAPs have different configuration information.
**Possible Causes**
The fields under **app** in the configuration files of these HAPs are inconsistent.
**Solution**
Check whether the fields under **app** are the same.
## 17700016 Application Installation Failure Due to Insufficient System Disk Space
**Error Message**
Failed to install the hap since the system disk space is insufficient.
**Description**
This error code is reported when the application fails to be installed due to insufficient system disk space.
**Possible Causes**
The system disk space is insufficient.
**Solution**
Check whether the system has sufficient disk space.
## 17700017 Application Installation Failure Because the Version to Install is Too Earlier
**Error Message**
Failed to install the hap since the version of the newly installed hap is too early.
**Description**
This error code is reported when the version number of the application to install is earlier than the version in use.
**Possible Causes**
The version number is earlier than the version in use.
**Solution**
Ensure that the version of the application to install is later than the version in use.
## 17700020 Failure to Uninstall Preinstalled Applications
**Error Message**
The preinstalled app cannot be uninstalled.
**Description**
This error code is reported when you attempt to uninstall a preinstalled application.
**Possible Causes**
1. You might want to uninstall a non-preinstalled application but passed the bundle name of a preinstalled app.
2. The preinstalled application cannot be uninstalled.
**Solution**
1. Check whether the bundle name is correct.
1. Check whether the preinstalled application can be uninstalled.
## 17700021 Invalid UID
**Error Message**
The specified uid is invalid.
**Description**
This error code is reported when the UID passed in the API is invalid.
**Possible Causes**
1. The UID is misspelled.
2. The UID does not exist.
**Solution**
1. Check whether the UID is correct.
2. Check whether the UID exists.
## 17700022 Invalid Source File
**Error Message**
The input source file is invalid.
**Description**
This error code is reported when the source file to be parsed is invalid.
**Possible Causes**
1. The source file to be parsed does not exist.
2. The source file to be parsed is not in ZIP format.
**Solution**
1. Check whether the source file to be parsed exists.
2. Check whether the source file to be parsed is in ZIP format.
## 17700023 Nonexistent Default Application
**Error Message**
The specified default app does not exist.
**Description**
This error code is reported when the specified default application does not exist.
**Possible Causes**
No default application is set for the device.
**Solution**
Check whether the default application is set on the device.
## 17700024 Nonexistent Configuration File
**Error Message**
Failed to get profile since no profile in the hap.
**Description**
This error code is reported when you attempt to obtain the configuration file that does not exist.
**Possible Causes**
1. The metadata name passed in the API does not exist in the configuration file.
2. The content of the configuration file is not in JSON format.
**Solution**
1. Check whether the metadata name in the **ability** or **extensionAbility** to be queried exists.
2. Check whether the content of the profile to be queried is in JSON format.
## 17700025 Invalid Type
**Error Message**
The specified type is invalid.
**Description**
The type is invalid.
**Possible Causes**
1. The type passed in the API is misspelled.
2. The type passed in the API does not exist.
**Solution**
Check whether the spelling of type is correct.
## 17700026 Application Disabled
**Error Message**
The specified bundle is disabled.
**Description**
This error code is reported when the specified application is disabled.
**Possible Causes**
The application on the device has been disabled and cannot be queried.
**Solution**
Check whether the application on the device is disabled.
## 17700027 Distributed Service Not Started
**Error Message**
The distributed service is not running.
**Description**
This error code is reported when the distributed service is not started.
**Possible Causes**
The device is not networked.
**Solution**
Check whether the device is networked.
## 17700028 Mismatch Between Ability and Type
**Error Message**
The ability does not match the type.
**Description**
This error code is reported when the ability and type passed in the API do not match.
**Possible Causes**
The ability and type are misspelled.
**Solution**
Check whether the spellings of ability and type are correct.
## 17700029 Disabled Ability
**Error Message**
The specified ability is disabled.
**Description**
This error code is reported when the specified ability is disabled.
**Possible Causes**
The specified ability is disabled.
**Solution**
Check whether the ability is disabled. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information.
## 17700030 Failure in Clearing Cache Files
**Error Message**
The specified bundle does not support clearing cache files.
**Description**
This error code is reported when the application does not support cache file clearing.
**Possible Causes**
The application is a system application and the **AllowAppDataNotCleared** field is configured in the signing certificate.
**Solution**
1. Check whether the application is a system application. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information and check whether the value of **isSystemApp** is **true**.
2. Check whether the **AllowAppDataNotCleared** field is configured for the application. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information and check whether the value of **userDataClearable** is **true**.
# faultLogger Error Codes
## 10600001 Service Faulty or Not Started
**Error Message**
The service is not running or broken.
**Description**
This error code is reported when the service is not started or is faulty.
**Possible Causes**
The hiview service is not started.
**Solution**
Retry the operation.
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册