提交 f1f27f48 编写于 作者: K king_he 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into 0610-a

......@@ -21,7 +21,7 @@ OpenHarmony is designed with a layered architecture, which from bottom to top, c
The system service layer provides a complete set of capabilities essential for OpenHarmony to offer services for apps through the framework layer. This layer consists of the following parts:
- Basic system capability subsystem set: Implements distributed app running, scheduling, and migration across OpenHarmony devices. This subsystem set provides the following basic capabilities: Intelligent Soft Bus, distributed data management, Distributed Scheduler, Utils, multimodal input, graphics, security, and AI.
- Basic system capability subsystem set: Implements distributed app running, scheduling, and migration across OpenHarmony devices. This subsystem set provides the following basic capabilities: Distributed Soft Bus (DSoftBus), distributed data management, Distributed Scheduler, Utils, multimodal input, graphics, security, and AI.
- Basic software service subsystem set: Provides OpenHarmony with common universal software services, including common event and notification, telephony, multimedia, and Design For X \(DFX\).
......@@ -42,42 +42,39 @@ This layer consists of system apps and third-party apps. Each OpenHarmony app is
## Technical Features<a name="section12212842173518"></a>
1. **Hardware collaboration and resource sharing**
**Hardware collaboration and resource sharing**
This feature is implemented through the following modules:
This feature is implemented through the following modules:
- Intelligent Soft Bus
- DSoftBus
Intelligent Soft Bus is a unified base for seamless interconnection among devices. It powers OpenHarmony with distributed communication capabilities to quickly discover and connect devices, and efficiently transmit data.
DSoftBus is a unified base for seamless interconnection among devices. It powers OpenHarmony with distributed communication capabilities to quickly discover and connect devices, and efficiently transmit data.
- Distributed data management
- Distributed data management
DSoftBus manages apps and user data distributed across different devices. Under such management, user data is no longer bound to a single physical device, and service logic is decoupled from storage. As your apps are running across devices, their data is seamlessly transmitted from one device to another, creating a foundation for a user experience that is smooth and consistent.
Intelligent Soft Bus manages apps and user data distributed across different devices. Under such management, user data is no longer bound to a single physical device, and service logic is decoupled from storage. As your apps are running across devices, their data is seamlessly transmitted from one device to another, creating a foundation for a user experience that is smooth and consistent.
- Distributed Scheduler
The Distributed Scheduler is designed based on technical features such as DSoftBus, distributed data management, and distributed profile. It builds a unified distributed service management mechanism \(including service discovery, synchronization, registration, and invocation\), and supports remote startup, remote invocation, binding/unbinding, and migration of apps across devices. This way, your app can select the most suitable device to perform distributed tasks based on the capabilities, locations, running status, and resource usage of different devices, as well as user habits and intentions.
- Distributed Scheduler
The Distributed Scheduler is designed based on technical features such as Intelligent Soft Bus, distributed data management, and distributed profile. It builds a unified distributed service management mechanism \(including service discovery, synchronization, registration, and invocation\), and supports remote startup, remote invocation, binding/unbinding, and migration of apps across devices. This way, your app can select the most suitable device to perform distributed tasks based on the capabilities, locations, running status, and resource usage of different devices, as well as user habits and intentions.
- Device virtualization
- Device virtualization
A distributed device virtualization platform enables cross-device resource convergence, device management, and data processing so that virtual peripherals can function as capability extensions of smartphones to form a super virtual terminal.
2. **One-time development for multi-device deployment**
**One-time development for multi-device deployment**
OpenHarmony provides you with the user application, ability, and UI frameworks. With these frameworks, you can develop your apps once, and then flexibly deploy them across a broad range of different devices.
OpenHarmony provides you with the user application, ability, and UI frameworks. With these frameworks, you can develop your apps once, and then flexibly deploy them across a broad range of different devices.
Consistent APIs ensure the operational compatibility of apps across devices.
Consistent APIs ensure the operational compatibility of apps across devices.
- Adaptation of device capabilities \(including CPU, memory, peripheral, and software resources\) can be previewed.
- Resources can be scheduled based on the compatibility between user apps and the software platform.
- Adaptation of device capabilities \(including CPU, memory, peripheral, and software resources\) can be previewed.
- Resources can be scheduled based on the compatibility between user apps and the software platform.
3. **A unified OS for flexible deployment**
**A unified OS for flexible deployment**
OpenHarmony enables hardware resources to be scaled with its component-based and small-scale designs. It can be deployed on demand for a diverse range of devices, including ARM, RISC-V, and x86 architectures, and providing RAM volumes ranging from hundreds of KiB to GiB.
OpenHarmony enables hardware resources to be scaled with its component-based and small-scale designs. It can be deployed on demand for a diverse range of devices, including ARM, RISC-V, and x86 architectures, and providing RAM volumes ranging from hundreds of KiB to GiB.
## OS Types<a name="section145241459142416"></a>
......@@ -113,10 +110,10 @@ The following table describes the subsystems of OpenHarmony. For details about t
| Subsystem| Description| Applicable To|
| -------- | -------- | -------- |
| Kernel| Supports small-sized LiteOS kernels that provide high performance and low power consumption for embedded devices and devices with limited resources, and supports Linux kernels that are applicable to the standard system.| Small system<br> Standard system |
| DFileSystem | Provides APIs for synchronizing local JS files. | Standard system |
| Kernel| Supports small-sized LiteOS kernels that provide high performance and low power consumption for embedded devices and devices with limited resources, and supports Linux kernels that are applicable to the standard system.| Small system<br>Standard system |
| Distributed File System | Provides APIs for synchronizing local JS files. | Standard system |
| Graphics | Consists of user interface (UI) components, layout, animator, font, input event, window management, and rendering and drawing modules. It is an application framework that can be built on the LiteOS to develop OpenHarmony applications for Internet of Things (IoT) devices with limited hardware resources or on the standard OS to develop OpenHarmony applications for standard- and large-system devices (for example, tablet and lite smart devices). | All systems |
| Driver | Constructed using the C object-oriented programming (OOP) language. It provides a unified driver platform and is compatible with different kernels by means of platform decoupling and kernel decoupling. This unified driver platform is designed to provide a more precise and efficient development environment, where you develop a driver that can be deployed on different systems supporting Hardware Driver Foundation (HDF). | All systems |
| Driver | Constructed using the C object-oriented programming (OOP) language. It provides a unified driver platform and is compatible with different kernels by means of platform decoupling and kernel decoupling. This unified driver platform is designed to provide a more precise and efficient development environment, where you develop a driver that can be deployed on different systems supporting HDF. | All systems |
| Power Management | Provides the following functions: restarting the system, managing running locks, managing and querying the system power status, querying and reporting the charging and battery status, and turning on/off the device screen, including adjusting the screen brightness. | Standard system |
| Pan-sensor | Contains sensors and misc devices. A sensor is a device to detect events or changes in an environment and send messages about the events or changes to another electronic device. Misc devices, including vibrators and LED lights, are used to send signals externally. You can call APIs to control the vibration of vibrators and lighting-on and lighting-off of LED lights. | Small system |
| Multimodal Input | OpenHarmony provides a Natural User Interface (NUI) for you to interact with your users. Unlike conventional categorization of input methods, OpenHarmony combines input methods of different dimensions into multimodal inputs, so you can easily arm your app with multi-dimensional, natural interaction features by using the application framework and system built-in UI components or APIs. Specifically, OpenHarmony currently supports traditional input methods such as key and touch inputs. | Standard system |
......@@ -125,14 +122,14 @@ The following table describes the subsystems of OpenHarmony. For details about t
| Account | Provides interconnection with vendors' cloud account apps on the device side, and query and update of the cloud account login status. | Standard system |
| Compilation and Building | Provides a compilation and building framework based on Generate Ninja (GN) and Ninja. | All systems |
| Test | The test-driven development mode is used during the development process. You can develop new cases or modify existing cases to test new or enhanced system features. The test helps you develop high-quality code in the development phase. | All systems |
| Data Management | Provides local data management and distributed data management:<br/> - Local app data management for lightweight preference databases and relational databases<br> - Distributed data service to provide apps with the capability to store data in the databases of different devices | Standard system |
| Data Management | Provides local data management and distributed data management:<br/>- Local app data management for lightweight preference databases and relational databases<br>- Distributed data service to provide apps with the capability to store data in the databases of different devices | Standard system |
| Programming Language Runtime | Provides the compilation and execution environment for programs developed with JavaScript or C/C++, basic libraries that support the runtime, and the runtime-associated APIs, compilers, and auxiliary tools. | All systems |
| Distributed Scheduler | Starts, registers, queries, and manages system services. | All systems |
| JS UI framework | OpenHarmony UI development framework that supports web-development-like paradigm. | All systems |
| Multimedia | Provides easy-to-use APIs for developing multimedia components such as audio, video, and camera, and enables apps to use multimedia resources of the system. | All systems |
| Event Notification | Provides the common event management capabilities that allow apps to subscribe to, unsubscribe from, publish, and receive common events (such as screen-on/off events and USB device attachment/detachment events). | Standard system |
| Common Event and Notification | Provides the common event management capabilities that allow apps to subscribe to, unsubscribe from, publish, and receive common events (such as screen-on/off events and USB device attachment/detachment events). | Standard system |
| Misc Services | Provides the function of setting the time. | Standard system |
| Bundle management | Provides bundle installation, uninstallation, update, and query capabilities. | All systems |
| Bundle management | Provides bundle installation, uninstall, update, and query capabilities. | All systems |
| Telephony | Provides basic communication capabilities of the cellular network, such as SIM cards, network search, cellular data, cellular calls, SMS, and MMS, as well as easy-to-use APIs for you to manage multiple types of calls and data network connections. | Standard system |
| Utils | Stores basic OpenHarmony components, which can be used by OpenHarmony subsystems and upper-layer apps. | All systems |
| Development Tools | Provides a performance profiler platform for you to analyze system issues such as memory and performance, including hdc used for device debugging, APIs for performance tracing, and a performance profiler framework. | Standard system |
......
......@@ -47,7 +47,7 @@
- [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/Readme-EN.md)
- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md)
- APIs
- [JS (eTS Included) APIs](reference/apis/Readme-EN.md)
- [JS and TS APIs](reference/apis/Readme-EN.md)
- Native APIs
- [Standard Library](reference/native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md)
......
# Ability Development
## When to Use
The stage model is an application development model introduced in API version 9. For details about this model, see [Stage Model Overview](stage-brief.md). To develop an ability based on the stage model, you must implement the following logic:
- Create Page abilities for an application that needs to be browsed on the screen and supports man-machine interaction, such as video playback and news browsing.
- Obtain ability configuration information, such as **ApplicationInfo**, **AbilityInfo**, and **HapModuleInfo**.
- Start an ability, start an ability with start options, start an ability with the returned result, or start an ability with an account ID.
- Request certain permissions from end users.
- Notify the ability stage and ability of environment configuration changes.
- Call common components. For details, see [Call Development](stage-call.md).
- Connect to and disconnect from the Service Extension ability. For details, see [Service Extension Ability Development](stage-serviceextension.md).
- Continue the application on another device. For details, see [Ability Continuation Development](stage-ability-continuation.md).
Unlike the FA model, the [stage model](stage-brief.md) requires you to declare the application package structure in the `module.json` and `app.json` files during application development. For details about the configuration file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). To develop abilities based on the stage model, implement the following logic:
- Create abilities for an application that involves screen viewing and human-machine interaction. You must implement the following scenarios: ability lifecycle callbacks, obtaining ability configuration, requesting permissions, and notifying environment changes.
- Start an ability. You need to implement ability startup on the same device, on a remote device, or with a specified UI page.
- Call abilities. For details, see [Call Development](stage-call.md).
- Connect to and disconnect from a Service Extension ability. For details, see [Service Extension Ability Development](stage-serviceextension.md).
- Continue the ability on another device. For details, see [Ability Continuation Development](stage-ability-continuation.md).
### Launch Type
The ability supports three launch types: singleton, multi-instance, and instance-specific.
The **launchType** item in the **module.json** file is used to specify the launch type.
The ability supports three launch types: singleton, multi-instance, and instance-specific. Each launch type, specified by `launchType` in the `module.json` file, specifies the action that can be performed when the ability is started.
| Launch Type | Description |Description |
| ----------- | ------- |---------------- |
......@@ -20,56 +16,49 @@ The **launchType** item in the **module.json** file is used to specify the launc
| singleton | Singleton | Only one instance exists in the system. If an instance already exists when an ability is started, that instance is reused.|
| specified | Instance-specific| The internal service of an ability determines whether to create multiple instances during running.|
By default, **singleton** is used.
## Available APIs
The table below describes the APIs provided by the **AbilityStage** class, which has the **context** attribute. For details about the APIs, see [AbilityStage](../reference/apis/js-apis-application-abilitystage.md).
By default, the singleton mode is used. The following is an example of the `module.json` file:
```json
{
"module": {
"abilities": [
{
"launchType": "singleton",
}
]
}
}
```
## Creating an Ability
### Available APIs
The table below describes the APIs provided by the `AbilityStage` class, which has the `context` attribute. For details about the APIs, see [AbilityStage](../reference/apis/js-apis-application-abilitystage.md).
**Table 1** AbilityStage APIs
|API|Description|
|:------|:------|
|void onCreate()|Called when an ability stage is created.|
|string onAcceptWant(want: Want)|Called when a specified ability is started.|
|void onConfigurationUpdated(config: Configuration)|Called when the global configuration is updated.|
|onCreate(): void|Called when an ability stage is created.|
|onAcceptWant(want: Want): string|Called when a specified ability is started.|
|onConfigurationUpdated(config: Configuration): void|Called when the global configuration is updated.|
The table below describes the APIs provided by the **Ability** class. For details about the APIs, see [Ability](../reference/apis/js-apis-application-ability.md).
The table below describes the APIs provided by the `Ability` class. For details about the APIs, see [Ability](../reference/apis/js-apis-application-ability.md).
**Table 2** Ability APIs
|API|Description|
|:------|:------|
|void onCreate(want: Want, param: AbilityConstant.LaunchParam)|Called when an ability is created.|
|void onDestroy()|Called when the ability is destroyed.|
|void onWindowStageCreate(windowStage: window.WindowStage)|Called when a **WindowStage** is created for the ability. You can use the **window.WindowStage** APIs to implement operations such as page loading.|
|void onWindowStageDestroy()|Called when the **WindowStage** is destroyed for the ability.|
|void onForeground()|Called when the ability is running in the foreground.|
|void onBackground()|Called when the ability is switched to the background.|
|void onNewWant(want: Want)|Called when the ability startup mode is set to singleton.|
|void onConfigurationUpdated(config: Configuration)|Called when the configuration of the environment where the ability is running is updated.|
The **Ability** class has the **context** attribute, which belongs to the **AbilityContext** class. The **AbilityContext** class has attributes such as **abilityInfo** and **currentHapModuleInfo**. For details about the APIs, see [AbilityContext](../reference/apis/js-apis-ability-context.md).
**Table 3** AbilityContext APIs
|API|Description|
|:------|:------|
|void startAbility(want: Want, callback: AsyncCallback<void>)|Starts an ability.|
|void startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>)|Starts an ability with start options.|
|void startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback<void>)|Starts an ability with the account ID.|
|void startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback<void>)|Starts an ability with the account ID and start options.|
|void startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>)|Starts an ability with the returned result.|
|void startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>)|Starts an ability with the returned result and start options.|
|void startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback<AbilityResult>)|Starts an ability with the returned result and account ID.|
|void startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback<void>)|Starts an ability with the returned result, account ID, and start options.|
|void terminateSelf(callback: AsyncCallback<void>)|Destroys the Page ability.|
|void terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>)|Destroys the Page ability with the returned result.|
## How to Develop
### Creating Page Abilities for an Application
To create Page abilities for an application on the stage model, you must implement the **AbilityStage** class and ability lifecycle callbacks, and use the **Window** APIs to set the pages. The sample code is as follows:
1. Import the **AbilityStage** module.
|onCreate(want: Want, param: AbilityConstant.LaunchParam): void|Called when an ability is created.|
|onDestroy(): void|Called when the ability is destroyed.|
|onWindowStageCreate(windowStage: window.WindowStage): void|Called when a `WindowStage` is created for the ability. You can use the `window.WindowStage` APIs to implement operations such as page loading.|
|onWindowStageDestroy(): void|Called when the `WindowStage` is destroyed for the ability.|
|onForeground(): void|Called when the ability is switched to the foreground.|
|onBackground(): void|Called when the ability is switched to the background.|
|onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void|Called when the ability launch type is set to `singleton`.|
|onConfigurationUpdated(config: Configuration): void|Called when the configuration of the environment where the ability is running is updated.|
### Implementing AbilityStage and Ability Lifecycle Callbacks
To create Page abilities for an application in the stage model, you must implement the `AbilityStage` class and ability lifecycle callbacks, and use the `Window` APIs to set the pages. The sample code is as follows:
1. Import the `AbilityStage` module.
```
import AbilityStage from "@ohos.application.AbilityStage"
```
2. Implement the **AbilityStage** class.
2. Implement the `AbilityStage` class.
```ts
export default class MyAbilityStage extends AbilityStage {
onCreate() {
......@@ -77,13 +66,13 @@ To create Page abilities for an application on the stage model, you must impleme
}
}
```
3. Import the **Ability** module.
3. Import the `Ability` module.
```js
import Ability from '@ohos.application.Ability'
```
4. Implement the lifecycle callbacks of the **Ability** class.
4. Implement the lifecycle callbacks of the `Ability` class.
In the **onWindowStageCreate(windowStage)** API, use **loadContent** to set the pages to be loaded by the application. For details about how to use the **Window** APIs, see [Window Development](../windowmanager/window-guidelines.md).
In the `onWindowStageCreate(windowStage)` API, use `loadContent` to set the application page to be loaded. For details about how to use the `Window` APIs, see [Window Development](../windowmanager/window-guidelines.md).
```ts
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
......@@ -100,7 +89,7 @@ To create Page abilities for an application on the stage model, you must impleme
windowStage.loadContent("pages/index").then((data) => {
console.log("MainAbility load content succeed with data: " + JSON.stringify(data))
}).catch((error) => {
console.error("MainAbility load content failed with error: "+ JSON.stringify(error))
console.error("MainAbility load content failed with error: " + JSON.stringify(error))
})
}
......@@ -117,8 +106,8 @@ To create Page abilities for an application on the stage model, you must impleme
}
}
```
### Obtaining AbilityStage and Ability Configuration Information
Both the **AbilityStage** and **Ability** classes have the **context** attribute. An application can obtain the context of the **Ability** instance through **this.context** to obtain detailed configuration information. The following example shows how the ability stage obtains the bundle code directory, HAP file name, ability name, and system language through the **context** attribute. The sample code is as follows:
### Obtaining AbilityStage and Ability Configurations
Both the `AbilityStage` and `Ability` classes have the `context` attribute. An application can obtain the context of an `Ability` instance through `this.context` to obtain the configuration details. The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the `context` attribute in the `AbilityStage` class. The sample code is as follows:
```ts
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
......@@ -137,7 +126,7 @@ export default class MyAbilityStage extends AbilityStage {
}
```
The following example shows how the ability obtains the bundle code directory, HAP file name, ability name, and system language through the **context** attribute. The sample code is as follows:
The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the `context` attribute in the `Ability` class. The sample code is as follows:
```ts
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
......@@ -155,9 +144,82 @@ export default class MainAbility extends Ability {
}
}
```
### Requesting Permissions
If an application needs to obtain user privacy information or use system capabilities, for example, obtaining location information or using the camera to take photos or record videos, it must request the permission from consumers. During application development, you need to specify the involved sensitive permissions, declare the required permissions in `module.json`, and use the `requestPermissionsFromUser` API to request the permission from consumers in the form of a dialog box. The following uses the permissions for calendar access as an example.
### Starting an Ability
An application can obtain the context of an **Ability** instance through **this.context** and then use the **StartAbility** API in the **AbilityContext** class to start the ability. The ability can be started by specifying **Want**, **StartOptions**, and **accountId**, and the operation result can be returned using a callback or **Promise** instance. The sample code is as follows:
Declare the required permissions in the `module.json` file.
```json
"requestPermissions": [
{
"name": "ohos.permission.READ_CALENDAR"
}
]
```
Request the permissions from consumers in the form of a dialog box:
```ts
let context = this.context
let permissions: Array<string> = ['ohos.permission.READ_CALENDAR']
context.requestPermissionsFromUser(permissions).then((data) => {
console.log("Succeed to request permission from user with data: " + JSON.stringify(data))
}).catch((error) => {
console.log("Failed to request permission from user with error: " + JSON.stringify(error))
})
```
### Notifying of Environment Changes
Environment changes include changes of global configurations and ability configurations. Currently, the global configurations include the system language and color mode. The change of global configurations is generally triggered by the configuration item in **Settings** or the icon in **Control Panel**. The ability configuration is specific to a single `Ability` instance, including the display ID, screen resolution, and screen orientation. The configuration is related to the display where the ability is located, and the change is generally triggered by the window. For details on the configuration, see [Configuration](../reference/apis/js-apis-configuration.md).
For an application in the stage model, when the configuration changes, its abilities are not restarted, but the `onConfigurationUpdated(config: Configuration)` callback is triggered. If the application needs to perform processing based on the change, you can overwrite `onConfigurationUpdated`. Note that the `Configuration` object in the callback contains all the configurations of the current ability, not only the changed configurations.
The following example shows the implement of the `onConfigurationUpdated` callback in the `AbilityStage` class. The callback is triggered when the system language and color mode are changed.
```ts
import Ability from '@ohos.application.Ability'
import ConfigurationConstant from '@ohos.application.ConfigurationConstant'
export default class MyAbilityStage extends AbilityStage {
onConfigurationUpdated(config) {
if (config.colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK) {
console.log('colorMode changed to dark')
}
}
}
```
The following example shows the implement of the `onConfigurationUpdated` callback in the `Ability` class. The callback is triggered when the system language, color mode, or display parameters (such as the direction and density) change.
```ts
import Ability from '@ohos.application.Ability'
import ConfigurationConstant from '@ohos.application.ConfigurationConstant'
export default class MainAbility extends Ability {
direction : number;
onCreate(want, launchParam) {
this.direction = this.context.config.direction
}
onConfigurationUpdated(config) {
if (this.direction !== config.direction) {
console.log(`direction changed to ${config.direction}`)
}
}
}
```
## Starting an Ability
### Available APIs
The `Ability` class has the `context` attribute, which belongs to the `AbilityContext` class. The `AbilityContext` class has the `abilityInfo`, `currentHapModuleInfo`, and other attributes and the APIs used for starting abilities. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md).
**Table 3** AbilityContext APIs
|API|Description|
|:------|:------|
|startAbility(want: Want, callback: AsyncCallback<void>): void|Starts an ability.|
|startAbility(want: Want, options?: StartOptions): Promise<void>|Starts an ability.|
|startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback<void>): void|Starts an ability with the account ID.|
|startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise<void>|Starts an ability with the account ID.|
|startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void|Starts an ability with the returned result.|
|startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult>|Starts an ability with the returned result.|
|startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback<AbilityResult>): void|Starts an ability with the execution result and account ID.|
|startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise<AbilityResult>|Starts an ability with the execution result and account ID.|
### Starting an Ability on the Same Device
An application can obtain the context of an `Ability` instance through `this.context` and then use the `startAbility` API in the `AbilityContext` class to start the ability. The ability can be started by specifying `Want`, `StartOptions`, and `accountId`, and the operation result can be returned using a callback or `Promise` instance. The sample code is as follows:
```ts
let context = this.context
var want = {
......@@ -165,20 +227,17 @@ var want = {
"bundleName": "com.example.MyApplication",
"abilityName": "MainAbility"
};
var options = {
windowMode: 0,
displayId: 2
};
context.startAbility(want, options).then((data) => {
context.startAbility(want).then((data) => {
console.log("Succeed to start ability with data: " + JSON.stringify(data))
}).catch((error) => {
console.error("Failed to start ability with error: "+ JSON.stringify(error))
})
```
### Starting an Ability on a Remote Device (Available only to System Applications)
>Note: The **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications. Therefore, cross-device ability startup applies only to system applications.
### Starting an Ability on a Remote Device
This feature applies only to system applications, since the `getTrustedDeviceListSync` API of the `DeviceManager` class is open only to system applications.
In the cross-device scenario, you must specify the ID of the remote device. The sample code is as follows:
```ts
let context = this.context
var want = {
......@@ -189,10 +248,10 @@ var want = {
context.startAbility(want).then((data) => {
console.log("Succeed to start remote ability with data: " + JSON.stringify(data))
}).catch((error) => {
console.error("Failed to start remote ability with error: "+ JSON.stringify(error))
console.error("Failed to start remote ability with error: " + JSON.stringify(error))
})
```
Obtain the ID of a specified device from **DeviceManager**. The sample code is as follows:
Obtain the ID of a specified device from `DeviceManager`. The sample code is as follows:
```ts
import deviceManager from '@ohos.distributedHardware.deviceManager';
function getRemoteDeviceId() {
......@@ -209,68 +268,57 @@ function getRemoteDeviceId() {
}
}
```
Request the permission `ohos.permission.DISTRIBUTED_DATASYNC ` from consumers. This permission is used for data synchronization. For details about the sample code for requesting the permission, see [Requesting Permissions](##requesting-permissions).
### Starting an Ability with the Specified Page
If the launch type of an ability is set to `singleton` and the ability has been started, the `onNewWant` callback is triggered when the ability is started again. You can pass start options through the `want`. For example, to start an ability with the specified page, use the `uri` or `parameters` parameter in the `want` to pass the page information. Currently, the ability in the stage model cannot directly use the `router` capability. You must pass the start options to the custom component and invoke the `router` method to display the specified page during the custom component lifecycle management. The sample code is as follows:
### Requesting Permissions
If an application requires certain permissions, such as storage, location information, and log access, the application must request the permissions from end users. After determining the required permissions, add the permissions in the **module.json** file and use **requestPermissionsFromUser** to request the permissions from end users in the form of a dialog box. The following uses the permissions for calendar access as an example.
Modify the **module.json** file as follows:
```json
"requestPermissions": [
{
"name": "ohos.permission.READ_CALENDAR"
}
]
```
Request the permissions from end users in the form of a dialog box:
When using `startAbility` to start an ability again, use the `uri` parameter in the `want` to pass the page information.
```ts
let context = this.context
let permissions: Array<string> = ['ohos.permission.READ_CALENDAR']
context.requestPermissionsFromUser(permissions).then((data) => {
console.log("Succeed to request permission from user with data: "+ JSON.stringify(data))
}).catch((error) => {
console.log("Failed to request permission from user with error: "+ JSON.stringify(error))
})
```
In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code is as follows:
```ts
let context = this.context
let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']
context.requestPermissionsFromUser(permissions).then((data) => {
console.log("Succeed to request permission from user with data: "+ JSON.stringify(data))
}).catch((error) => {
console.log("Failed to request permission from user with error: "+ JSON.stringify(error))
})
async function reStartAbility() {
try {
await this.context.startAbility({
bundleName: "com.sample.MyApplication",
abilityName: "MainAbility",
uri: "pages/second"
})
console.log('start ability succeed')
} catch (error) {
console.error(`start ability failed with ${error.code}`)
}
}
```
### Notifying of Environment Configuration Changes
When the global configuration, for example, system language and color mode, changes, the **onConfigurationUpdated** API is called to notify the ability stage and ability. System applications can update the system language and color mode through the **updateConfiguration** API. The following example shows the implement of the **onConfigurationUpdated** callback in the **AbilityStage** class. The callback is triggered when the system language and color mode change. The sample code is as follows:
Obtain the `want` parameter that contains the page information from the `onNewWant` callback of the ability.
```ts
import Ability from '@ohos.application.Ability'
import ConfigurationConstant from '@ohos.application.ConfigurationConstant'
export default class MyAbilityStage extends AbilityStage {
onConfigurationUpdated(config) {
console.log("MyAbilityStage onConfigurationUpdated")
console.log("MyAbilityStage config language" + config.language)
console.log("MyAbilityStage config colorMode" + config.colorMode)
export default class MainAbility extends Ability {
onNewWant(want, launchParams) {
globalThis.newWant = want
}
}
```
The following example shows the implement of the **onConfigurationUpdated** callback in the **Ability** class. The callback is triggered when the system language, color mode, and display parameters (such as the direction and density) change. The sample code is as follows:
Obtain the `want` parameter that contains the page information from the custom component and process the route based on the URI.
```ts
import Ability from '@ohos.application.Ability'
import ConfigurationConstant from '@ohos.application.ConfigurationConstant'
export default class MainAbility extends Ability { {
onConfigurationUpdated(config) {
console.log("MainAbility onConfigurationUpdated")
console.log("MainAbility config language" + config.language)
console.log("MainAbility config colorMode" + config.colorMode)
console.log("MainAbility config direction" + config.direction)
console.log("MainAbility config screenDensity" + config.screenDensity)
console.log("MainAbility config displayId" + config.displayId)
import router from '@system.router'
@Entry
@Component
struct Index {
newWant = undefined
onPageShow() {
console.info('Index onPageShow')
let newWant = globalThis.newWant
if (newWant.hasOwnProperty("uri")) {
router.push({ uri: newWant.uri });
globalThis.newWant = undefined
}
}
}
```
## Samples
The following sample is provided to help you better understand how to develop an ability on the stage model:
- [`StageCallAbility`: Stage Ability Creation and Usage (eTS) (API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility)
- [`StageCallAbility`: Stage Call Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility)
......@@ -257,7 +257,7 @@ Data of a temporary widget is not persistently stored. If the widget framework i
### Developing the Widget UI Page
You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programmed widget.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> Currently, only the JavaScript-based web-like development paradigm can be used to develop the widget UI.
- hml:
......
......@@ -54,7 +54,7 @@ They are organized as follows:
- [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/Readme-EN.md)
- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md)
- APIs
- [JS (eTS Included) APIs](reference/apis/Readme-EN.md)
- [JS and TS APIs](reference/apis/Readme-EN.md)
- Native APIs
- [Standard Library](reference/native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md)
......
......@@ -36,6 +36,8 @@ Then, equip yourself for developing the key features, with the following guideli
- [Device Usage Statistics](device-usage-statistics/device-usage-statistics-overview.md)
- [DFX](dfx/hiappevent-overview.md)
- [Internationalization](internationalization/international-overview.md)
- [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md)
- [Using Native APIs in Application Projects](napi/napi-guidelines.md)
### Tools
......@@ -51,6 +53,8 @@ To make you better understand how functions work together and jumpstart your app
API references encompass all components and APIs available in OpenHarmony, helping you use and integrate APIs more effectively.
They are organized as follows:
- [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/js-components-common-attributes.md)
- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/ts-universal-events-click.md)
- [API Reference](reference/apis/js-apis-DataUriUtils.md)
- [JS and TS APIs](reference/apis/js-apis-DataUriUtils.md)
- Native APIs
- [Standard Library](reference/native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md)
......@@ -289,4 +289,4 @@ export default {
The following sample is provided to help you better understand how to develop background task management:
- [<idp:inline class="- topic/inline " val="code" displayname="code" id="code1035211243011" tempcmdid="code1035211243011">BackgroundTaskManager</idp:inline>: Background Task Management (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/ResourcesSchedule/BackgroundTaskManager)
- [`BackgroundTaskManager`: Background Task Management (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/ResourcesSchedule/BackgroundTaskManager)
......@@ -15,7 +15,7 @@ JS application event logging APIs are provided by the **hiAppEvent** module.
| write(string eventName, EventType type, object keyValues, AsyncCallback\<void> callback): void | void | Logs application events in asynchronous mode. This method uses an asynchronous callback to return the result. |
| write(string eventName, EventType type, object keyValues): Promise\<void> | Promise\<void> | Logs application events in asynchronous mode. This method uses a promise to return the result. |
When an asynchronous callback is used, the return value can be processed directly in the callback. When a promise is used, the return value can also be processed in the promise in a similar way. For details about the result codes, see [Event Verification Result Codes](hiappevent-overview.md#Event Verification Result Codes).
When an asynchronous callback is used, the return value can be processed directly in the callback. When a promise is used, the return value can also be processed in the promise in a similar way. For details about the result codes, see [Event Verification Result Codes](#event-verification-result-codes).
**APIs for Event Logging Configuration**
......@@ -23,6 +23,24 @@ When an asynchronous callback is used, the return value can be processed directl
| ------------------------------ | ------------ | ------------------------------------------------------------ |
| configure(ConfigOption config) | boolean | Sets the configuration options for application event logging.<br>The value **true** indicates that the operation is successful, and value **false** indicates the opposite. |
## Event Verification Result Codes
| Result Code | Cause | Check Rule | Processing Method |
| ----------- | ---------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 0 | None | Event verification is successful. | Event logging is normal. No action is required. |
| -1 | Invalid event name | The event name is not empty and contains a maximum of 48 characters.<br/>The event name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore (\_).<br/>The event name does not start with a digit or underscore (_). | Ignore this event and do not perform logging. |
| -2 | Invalid event parameter type | The event name must be a string.<br/>The event type must be a number.<br/>The key value must be an object. | Ignore this event and do not perform logging. |
| -99 | Application event logging disabled | The application event logging function is disabled. | Ignore this event and do not perform logging. |
| -100 | Unknown error | None | Ignore this event and do not perform logging. |
| 1 | Invalid key name | The key name is not empty and contains a maximum of 16 characters.<br/>The key name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore (\_).<br/>The key name does not start with a digit or underscore (\_).<br/>The key name does not end with an underscore (_). | Ignore the key-value pair and continue to perform logging. |
| 2 | Invalid key type | The key must be a string. | Ignore the key-value pair and continue to perform logging. |
| 3 | Invalid value type | The supported value types vary depending on the programming language:<br/>boolean, number, string, or Array [basic element] | Ignore the key-value pair and continue to perform logging. |
| 4 | Value too long | The value can contain a maximum of 8*1024 characters. | Ignore the key-value pair and continue to perform logging. |
| 5 | Excess key-value pairs | The number of key-value pairs must be less than or equal to 32. | Ignore the excess key-value pairs and continue to perform logging. |
| 6 | Excess elements in a list value | The number of elements in a list value must be less than or equal to 100. | Truncate the list with only the first 100 elements retained, and continue to perform logging. |
| 7 | Invalid list value | A list value can only be a basic element.<br/>The elements in a list value must be of the same type. | Ignore the key-value pair and continue to perform logging. |
## How to Develop
In this example, an application event is logged after the application startup execution page is loaded.
......
......@@ -7,20 +7,3 @@ HiAppEvent provides event logging APIs for applications to log the fault, statis
The HiAppEvent module of OpenHarmony can be used to develop application event services and provide functions related to application events, including flushing application events to a disk and querying historical application event data.
**Logging**: Logs changes caused by user operations to provide service data for development, product, and O&M analysis.
## Event Verification Result Codes
| Result Code | Cause | Check Rule | Processing Method |
| ----------- | ---------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 0 | None | Event verification is successful. | Event logging is normal. No action is required. |
| -1 | Invalid event name | The event name is not empty and contains a maximum of 48 characters.<br/>The event name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore (\_).<br/>The event name does not start with a digit or underscore (_). | Ignore this event and do not perform logging. |
| -2 | Invalid event parameter type | The event name must be a string.<br/>The event type must be a number.<br/>The key value must be an object. | Ignore this event and do not perform logging. |
| -99 | Application event logging disabled | The application event logging function is disabled. | Ignore this event and do not perform logging. |
| -100 | Unknown error | None | Ignore this event and do not perform logging. |
| 1 | Invalid key name | The key name is not empty and contains a maximum of 16 characters.<br/>The key name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore (\_).<br/>The key name does not start with a digit or underscore (\_).<br/>The key name does not end with an underscore (_). | Ignore the key-value pair and continue to perform logging. |
| 2 | Invalid key type | The key must be a string. | Ignore the key-value pair and continue to perform logging. |
| 3 | Invalid value type | The supported value types vary depending on the programming language:<br/>boolean, number, string, or Array [basic element] | Ignore the key-value pair and continue to perform logging. |
| 4 | Value too long | The value can contain a maximum of 8*1024 characters. | Ignore the key-value pair and continue to perform logging. |
| 5 | Excess key-value pairs | The number of key-value pairs must be less than or equal to 32. | Ignore the excess key-value pairs and continue to perform logging. |
| 6 | Excess elements in a list value | The number of elements in a list value must be less than or equal to 100. | Truncate the list with only the first 100 elements retained, and continue to perform logging. |
| 7 | Invalid list value | A list value can only be a basic element.<br/>The elements in a list value must be of the same type. | Ignore the key-value pair and continue to perform logging. |
\ No newline at end of file
# Native APIs
- [Using Native APIs in Application Projects](napi-guidelines.md)
- [Raw File Development](rawfile-guidelines.md)
# Raw File Development
## When to Use
This document describes how to use the native Rawfile APIs to manage raw file directories and files in OpenHarmony. The table below describes the APIs.
## Available APIs
| API | Description |
| :----------------------------------------------------------- | :--------------------------------------- |
| NativeResourceManager *OH_ResourceManager_InitNativeResourceManager(napi_env env, napi_value jsResMgr) | Initializes the native resource manager. |
| RawDir *OH_ResourceManager_OpenRawDir(const NativeResourceManager *mgr, const char *dirName) | Opens a raw file directory. |
| int OH_ResourceManager_GetRawFileCount(RawDir *rawDir) | Obtains the number of raw files in the specified directory.|
| const char *OH_ResourceManager_GetRawFileName(RawDir *rawDir, int index) | Obtains the name of a raw file. |
| RawFile *OH_ResourceManager_OpenRawFile(const NativeResourceManager *mgr, const char *fileName) | Opens a raw file. |
| long OH_ResourceManager_GetRawFileSize(RawFile *rawFile) | Obtains the size of a raw file. |
| int OH_ResourceManager_SeekRawFile(const RawFile *rawFile, long offset, int whence) | Seeks a data read/write position in a raw file based on the specified offset. |
| long OH_ResourceManager_GetRawFileOffset(const RawFile *rawFile) | Obtains the offset. |
| int OH_ResourceManager_ReadRawFile(const RawFile *rawFile, void *buf, size_t length) | Reads a raw file. |
| void OH_ResourceManager_CloseRawFile(RawFile *rawFile) | Closes a raw file to release resources. |
| void OH_ResourceManager_CloseRawDir(RawDir *rawDir) | Closes a raw file directory to release resources. |
| bool OH_ResourceManager_GetRawFileDescriptor(const RawFile *rawFile, RawFileDescriptor &descriptor) | Obtains the file description (FD) of a raw file. |
| bool OH_ResourceManager_ReleaseRawFileDescriptor(const RawFileDescriptor &descriptor) | Releases the FD of a raw file. |
| void OH_ResourceManager_ReleaseNativeResourceManager(NativeResourceManager *resMgr) | Releases native resource manager resources. |
## How to Develop
1. Add the header file.
```c++
#include "raw_file_manager.h"
```
2. Call **OH_ResourceManager_InitNativeResourceManager(napi_env env, napi_value jsResMgr)** to obtain a **NativeResourceManager** instance.
```js
// Call the JS API to pass the JS resource manager.
import resManager from '@ohos.resourceManager'
import rawfileTest from 'librawFileTest.so'
resManager.getResourceManager().then(resmgr => {
rawfileTest.testRawFile("test", resmgr, (error, value) => {
console.log("test rawFile");
})
});
```
```c++
// The C++ API obtains and parses the parameters passed by the JS API.
NativeResourceManager* nativeResourceManager = nullptr;
std::string path;
if (i == 0 && valueType == napi_string) {
// Parse the first parameter, which is the file or directory path relative to the raw file directory.
......
path = buf.data();
} else if (i == 1 && valueType == napi_object) {
// Parse the second parameter, which is the resource manager.
nativeResourceManager = OH_ResourceManager_InitNativeResourceManager(env, argv[i]);
}
```
3. Call **OH_ResourceManager_OpenRawDir** to obtain a **RawDir** instance based on the **NativeResourceManager** instance.
```c++
RawDir* rawDir = OH_ResourceManager_OpenRawDir(nativeResourceManager, path.c_str());
```
4. Call **OH_ResourceManager_GetRawFileCount** to obtain the total number of raw files in the directory based on the **RawDir** instance.
```c++
int count = OH_ResourceManager_GetRawFileCount(rawDir);
```
5. Call **OH_ResourceManager_GetRawFileName** to obtain the name of the raw file based on the specified index.
```c++
for (int index = 0; index < count; index++) {
std::string fileName = OH_ResourceManager_GetRawFileName(rawDir, index);
}
```
6. Call **OH_ResourceManager_OpenRawFile** to obtain a **RawFile** instance based on the specified file name.
```c++
RawFile* rawFile = OH_ResourceManager_OpenRawFile(nativeResourceManager, fileName.c_str());
```
7. Call **OH_ResourceManager_GetRawFileSize** to obtain the size of the raw file.
```c++
long rawFileSize = OH_ResourceManager_GetRawFileSize(rawFile);
```
8. Call **OH_ResourceManager_SeekRawFile** to seek a data read/write position in the raw file based on the specified offset.
```c++
int position = OH_ResourceManager_SeekRawFile(rawFile, 10, 0);
int position = OH_ResourceManager_SeekRawFile(rawFile, 0 , 1);
int position = OH_ResourceManager_SeekRawFile(rawFile, -10, 2);
```
9. Call **OH_ResourceManager_GetRawFileOffset** to obtain the raw file offset.
```c++
long rawFileOffset = OH_ResourceManager_GetRawFileOffset(rawFile)
```
10. Call **OH_ResourceManager_ReadRawFile** to read a raw file.
```c++
std::unique_ptr<char[]> mediaData = std::make_unique<char[]>(rawFileSize);
long rawFileOffset = OH_ResourceManager_ReadRawFile(rawFile, mediaData.get(), rawFileSize);
```
11. Call **OH_ResourceManager_CloseRawFile** to close the file to release resources.
```c++
OH_ResourceManager_CloseRawFile(rawFile);
```
12. Call **OH_ResourceManager_CloseRawDir** to close the raw file directory.
```c++
OH_ResourceManager_CloseRawDir(rawDir);
```
13. Call **OH_ResourceManager_GetRawFileDescriptor** to obtain **RawFileDescriptor** of the raw file.
```c++
RawFileDescriptor descriptor;
bool result = OH_ResourceManager_GetRawFileDescriptor(rawFile, descriptor);
```
14. Call **OH_ResourceManager_ReleaseRawFileDescriptor** to release the FD of the raw file.
```c++
OH_ResourceManager_ReleaseRawFileDescriptor(descriptor);
```
15. Call **OH_ResourceManager_ReleaseNativeResourceManager** to release the native resource manager.
```c++
OH_ResourceManager_ReleaseNativeResourceManager(nativeResourceManager);
```
......@@ -94,7 +94,8 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
4. Add a **Text** component.
- In the **second.ets** file, set the message text content to **Hi there**. The sample code is as follows:
```
```ts
// second.ets
@Entry
@Component
struct Second {
......@@ -130,7 +131,8 @@ You can implement page redirection through the page router, which finds the targ
- In the **index.ets** file:
```
```ts
// index.ets
import router from '@ohos.router';
@Entry
......@@ -163,7 +165,8 @@ You can implement page redirection through the page router, which finds the targ
- In the **second.ets** file:
```
```ts
// second.ets
import router from '@ohos.router';
@Entry
......
......@@ -41,7 +41,8 @@
After the project synchronization is complete, choose **entry** &gt; **src** &gt; **main** &gt; **ets** &gt; **MainAbility** &gt; **pages** in the **Project** window and open the **index.ets** file. You can see that the file contains a **&lt;Text&gt;** component. The sample code in the **index.ets** file is shown below:
```
```ts
// index.ets
@Entry
@Component
struct Index {
......@@ -66,7 +67,8 @@
On the default page, add a **&lt;Button&gt;** component to respond to user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below:
```
```ts
// index.ets
@Entry
@Component
struct Index {
......@@ -119,7 +121,8 @@
Add **&lt;Text&gt;** and **&lt;Button&gt;** components and set their styles, as you do for the first page. The sample code in the **second.ets** file is shown below:
```
```ts
// second.ets
@Entry
@Component
struct Second {
......@@ -161,7 +164,8 @@ You can implement page redirection through the page router, which finds the targ
In the **index.ets** file of the first page, bind the **onClick** event to the **Next** button so that clicking the button redirects the user to the second page. The sample code in the **index.ets** file is shown below:
```
```ts
// index.ets
import router from '@ohos.router';
@Entry
......@@ -205,7 +209,8 @@ You can implement page redirection through the page router, which finds the targ
In the **second.ets** file of the second page, bind the **onClick** event to the **Back** button so that clicking the button redirects the user back to the first page. The sample code in the **second.ets** file is shown below:
```
```ts
// second.ets
import router from '@ohos.router';
@Entry
......
......@@ -40,7 +40,8 @@
After the project synchronization is complete, choose **entry** &gt; **src** &gt; **main** &gt; **js** &gt; **MainAbility** &gt; **pages** &gt; **index** in the **Project** window and open the **index.hml** file. You can see that the file contains a **&lt;Text&gt;** component. The sample code in the **index.hml** file is shown below:
```
```html
<!--index.hml-->
<div class="container">
<text class="title">
Hello World
......@@ -53,7 +54,8 @@
On the default page, add an **&lt;input&gt;** component of the button type to respond to user clicks and implement redirection to another page. The sample code in the **index.hml** file is shown below:
```
```html
<!--index.hml-->
<div class="container">
<text class="title">
Hello World
......@@ -69,7 +71,7 @@
From the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **js** &gt; **MainAbility** &gt; **pages** &gt; **index**, open the **index.css** file, and set the page styles, such as the width, height, font size, and spacing. The sample code in the **index.css** file is shown below:
```
```css
.container {
display: flex;
flex-direction: column;
......@@ -119,7 +121,8 @@
Add **&lt;Text&gt;** and **&lt;Button&gt;** components and set their styles, as you do for the first page. The sample code in the **second.hml** file is shown below:
```
```html
<!--second.hml-->
<div class="container">
<text class="title">
Hi there
......@@ -132,7 +135,7 @@
3. Set the page style in the **second.css** file. The sample code in the **second.css** file is shown below:
```
```css
.container {
display: flex;
flex-direction: column;
......@@ -172,7 +175,8 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin
In the **index.js** file of the first page, bind the **onclick** method to the button so that clicking the button redirects the user to the second page. The sample code in the **index.js** file is shown below:
```
```js
// index.js
import router from '@ohos.router';
export default {
......@@ -189,7 +193,8 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin
In the **second.ets** file of the second page, bind the **back** method to the **Back** button so that clicking the button redirects the user back to the first page. The sample code in the **second.js** file is shown below:
```
```js
// second.js
import router from '@ohos.router';
export default {
......
......@@ -9,6 +9,7 @@
- [@ohos.application.AbilityConstant](js-apis-application-abilityConstant.md)
- [@ohos.application.abilityDelegatorRegistry](js-apis-abilityDelegatorRegistry.md)
- [@ohos.application.AbilityStage ](js-apis-application-abilitystage.md)
- [@ohos.application.abilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md)
- [@ohos.application.appManager](js-apis-appmanager.md)
- [@ohos.application.Configuration](js-apis-configuration.md)
- [@ohos.application.ConfigurationConstant](js-apis-configurationconstant.md)
......@@ -30,6 +31,7 @@
- ability/[dataAbilityHelper](js-apis-dataAbilityHelper.md)
- app/[context](js-apis-Context.md)
- application/[AbilityContext](js-apis-ability-context.md)
- application/[ApplicationContext](js-apis-application-applicationContext.md)
- application/[abilityDelegator](js-apis-application-abilityDelegator.md)
- application/[abilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md)
- application/[abilityMonitor](js-apis-application-abilityMonitor.md)
......@@ -44,6 +46,7 @@
- application/[ProcessRunningInfo](js-apis-processrunninginfo.md)
- application/[ServiceExtensionContext](js-apis-service-extension-context.md)
- application/[shellCmdResult](js-apis-application-shellCmdResult.md)
- application/[MissionInfo](js-apis-application-missionInfo.md)
- Common Event and Notification
......@@ -58,6 +61,14 @@
- [@ohos.bundle](js-apis-Bundle.md)
- [@ohos.bundleState](js-apis-deviceUsageStatistics.md)
- [@ohos.zlib](js-apis-zlib.md)
- bundle/[AbilityInfo](js-apis-bundle-AbilityInfo.md)
- bundle/[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)
- bundle/[BundleInfo](js-apis-bundle-BundleInfo.md)
- bundle/[CustomizeData](js-apis-bundle-CustomizeData.md)
- bundle/[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)
- bundle/[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)
- bundle/[Metadata](js-apis-bundle-Metadata.md)
- bundle/[ModuleInfo](js-apis-bundle-ModuleInfo.md)
- UI Page
......@@ -180,6 +191,7 @@
- [@ohos.multimodalInput.inputDevice](js-apis-inputdevice.md)
- [@ohos.multimodalInput.inputEventClient](js-apis-inputeventclient.md)
- [@ohos.multimodalInput.inputMonitor](js-apis-inputmonitor.md)
- [@ohos.multimodalInput.inputEvent](js-apis-inputevent.md)
- [@ohos.power](js-apis-power.md)
- [@ohos.runningLock](js-apis-runninglock.md)
- [@ohos.sensor](js-apis-sensor.md)
......
......@@ -508,7 +508,7 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ------------ |
| hapFilePath | string | Yes | Path where the HAP file is stored. The path should point to the relative directory of the current application's data directory.|
| bundleFlags | number | Yes | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. The value must be greater than 0.|
| bundleFlags | number | Yes | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
**Return value**
| Type | Description |
......@@ -543,8 +543,8 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ------------ |
| hapFilePath | string | Yes | Path where the HAP file is stored. The path should point to the relative directory of the current application's data directory.|
| bundleFlags | number | Yes | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. The value must be greater than 0.|
| callback| AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the information about the bundles. |
| bundleFlags | number | Yes | Flags used to specify information contained in the **BundleInfo** object that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| callback| AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the information about the bundles.|
**Example**
......@@ -1611,8 +1611,9 @@ Enumerates bundle flags.
| GET_ABILITY_INFO_SYSTEMAPP_ONLY<sup>8+</sup> | 0x00000080 | Obtains the ability information of system applications.|
| GET_ABILITY_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000100 | Obtains information about disabled abilities. |
| GET_APPLICATION_INFO_WITH_DISABLE<sup>8+</sup> | 0x00000200 | Obtains information about disabled applications. |
| GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT <sup>9+</sup> | 0x00000400 | Obtains the signing certificate fingerprint of the application. |
| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information. |
| GET_BUNDLE_WITH_HASH_VALUE<sup>9+</sup> | 0x00000030 | Obtains the bundle information with the information about hash value. |
| GET_BUNDLE_WITH_HASH_VALUE<sup>9+</sup> | 0x00000030 | Obtains information about the bundle that contains a hash value. |
## BundleOptions
......
......@@ -44,10 +44,10 @@ Starts an ability. This API uses a callback to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -73,11 +73,11 @@ Starts an ability. This API uses a callback to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -106,16 +106,16 @@ Starts an ability. This API uses a promise to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | No| Parameters used for starting the ability.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | No| Parameters used for starting the ability.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -147,10 +147,10 @@ Starts an ability. This API uses a callback to return the execution result when
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -175,11 +175,11 @@ Starts an ability. This API uses a callback to return the execution result when
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -208,17 +208,17 @@ Starts an ability. This API uses a promise to return the execution result when t
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | No| Parameters used for starting the ability.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | No| Parameters used for starting the ability.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Promise used to return the result.|
**Example**
......@@ -244,9 +244,9 @@ Terminates this ability. This API uses a callback to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
**Example**
......@@ -267,9 +267,9 @@ Terminates this ability. This API uses a promise to return the result.
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example**
......@@ -292,10 +292,10 @@ Terminates this ability. This API uses a callback to return the information to t
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -321,15 +321,15 @@ Terminates this ability. This API uses a promise to return information to the ca
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -355,15 +355,15 @@ Obtains the caller interface of the specified ability, and if the specified abil
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Caller&gt; | Promise used to return the caller object to communicate with.|
| Type| Description|
| -------- | -------- |
| Promise&lt;Caller&gt; | Promise used to return the caller object to communicate with.|
**Example**
......@@ -397,10 +397,10 @@ Requests permissions from the user by displaying a pop-up window. This API uses
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | Yes| Permissions to request.|
| callback | AsyncCallback&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | Yes| Permissions to request.|
| callback | AsyncCallback&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
**Example**
......@@ -423,15 +423,15 @@ Requests permissions from the user by displaying a pop-up window. This API uses
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | Yes| Permissions to request.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | Yes| Permissions to request.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example**
......@@ -456,10 +456,10 @@ Sets the label of the ability displayed in the task. This API uses a callback to
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| label | string | Yes| Label of the ability to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| label | string | Yes| Label of the ability to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
**Example**
......@@ -480,15 +480,15 @@ Sets the label of the ability displayed in the task. This API uses a promise to
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| label | string | Yes| Label of the ability to set.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| label | string | Yes| Label of the ability to set.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example**
......@@ -499,3 +499,24 @@ Sets the label of the ability displayed in the task. This API uses a promise to
console.log('failed:' + JSON.stringify(error));
});
```
## AbilityContext.isTerminating
isTerminating(): boolean;
Checks whether this ability is in the terminating state.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type| Description|
| -------- | -------- |
| bool | The value **true** means that the ability is in terminating state, and **false** means the opposite.|
**Example**
```js
var isTerminating = this.context.isTerminating();
console.log('ability state :' + isTerminating);
```
# AbilityStage
> **NOTE**<br>
> **NOTE**<br/>
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -45,15 +45,15 @@ Called when a specified ability is started.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes | Information about the ability to start, such as the ability name and bundle name. |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.|
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| string | Returns an ability ID. If this ability has been started, no new instance is created and the ability is placed at the top of the stack. Otherwise, a new instance is created and started. |
| string | Returns an ability ID. If this ability has been started, no new instance is created and the ability is placed at the top of the stack. Otherwise, a new instance is created and started.|
**Example**
......@@ -77,9 +77,9 @@ Called when the global configuration is updated.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes | Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode. |
| config | [Configuration](js-apis-configuration.md) | Yes| Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode.|
**Example**
......@@ -92,10 +92,12 @@ Called when the global configuration is updated.
```
## AbilityStage.context
context: AbilityStageContext;
Describes the configuration information about the context.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Description |
| ----------- | --------------------------- | ------------------------------------------------------------ |
| context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup. |
| Name | Type | Description |
| ----------- | --------------------------- | ------------------------------------------------------------ |
| context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup.|
......@@ -6,6 +6,11 @@
Provides application-level context and APIs for registering and deregistering the ability lifecycle listener in an application.
## Modules to Import
```
import Ability from '@ohos.application.Ability';
```
## How to Use
......
......@@ -39,3 +39,4 @@ Provides the application information.
| accessTokenId<sup>8+</sup> | number | Yes | No | Access token ID of the application. |
| uid<sup>8+</sup> | number | Yes | No | UID of the application. |
| entityType<sup>8+</sup> | string | Yes | No | Entity type of the application. |
| fingerprint<sup>9+</sup> | string | Yes | No | Signing certificate fingerprint of the application, that is, the SHA-256 checksum of the signing certificate that you apply for for the application. |
......@@ -3,14 +3,13 @@
> **NOTE**<br/>
> 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.
```js
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility';
```
Implements the extension context. This module is inherited from **Context**.
## Modules to Import
```js
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility';
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
......@@ -52,8 +52,7 @@ Obtains the fault information about the current process. This API uses an asynch
| 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.
| 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. |
**Example**
```js
......
# FeatureAbility Module (JavaScript)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Constraints
......@@ -44,7 +44,7 @@ featureAbility.startAbility(
deviceId: "",
bundleName: "com.example.myapplication",
/* In the FA model, abilityName consists of package and ability name. */
abilityName: "com.example.entry.secondAbility",,
abilityName: "com.example.entry.secondAbility",
uri: ""
},
},
......@@ -139,7 +139,7 @@ Starts an ability. This API uses a callback to return the execution result when
**Example**
```javascript
import featureAbility from '@ohos.ability.featureability';
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant'
featureAbility.startAbilityForResult(
{
......@@ -157,7 +157,7 @@ featureAbility.startAbilityForResult(
},
},
(err, data) => {
console.info("err: " + JSON.stringfy(err) + "data: " + JSON.stringfy(data))
console.info("err: " + JSON.stringify(err) + "data: " + JSON.stringify(data))
}
)
```
......@@ -185,7 +185,7 @@ Starts an ability. This API uses a promise to return the execution result when t
**Example**
```javascript
import featureAbility from '@ohos.ability.featureability';
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant'
featureAbility.startAbilityForResult(
{
......@@ -291,7 +291,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Example**
```javascript
import featureAbility from '@ohos.ability.featureability';
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant'
featureAbility.terminateSelfWithResult(
{
......@@ -343,7 +343,7 @@ Checks whether the main window of this ability has the focus. This API uses a ca
**Example**
```javascript
import featureAbility from '@ohos.ability.featureability';
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.hasWindowFocus()
```
......@@ -391,7 +391,7 @@ Obtains the **Want** object sent from this ability. This API uses a callback to
**Example**
```javascript
import featureAbility from '@ohos.ability.featureability';
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant()
```
......@@ -414,7 +414,7 @@ Obtains the **Want** object sent from this ability. This API uses a promise to r
**Example**
```javascript
import featureAbility from '@ohos.ability.featureability';
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant().then((data) => {
console.info("==========================>getWantCallBack=======================>");
});
......@@ -437,7 +437,7 @@ Obtains the application context.
**Example**
```javascript
import featureAbility from '@ohos.ability.featureability';
import featureAbility from '@ohos.ability.featureAbility';
var context = featureAbility.getContext()
context.getBundleName()
```
......@@ -461,7 +461,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Example**
```javascript
import featureAbility from '@ohos.ability.featureability';
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf()
```
......@@ -484,7 +484,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Example**
```javascript
import featureAbility from '@ohos.ability.featureability';
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf().then((data) => {
console.info("==========================>terminateSelfCallBack=======================>");
});
......@@ -918,7 +918,6 @@ Enumerates operation types of the Data ability.
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| want | Read-only | [Want](js-apis-application-Want.md) | Yes | Information about the ability to start. |
| abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.|
|
## flags
......
......@@ -21,15 +21,15 @@ Provides the constants of all rule types.
| Name | Type| Description |
| ---------------------------------- | -------- | ------------------------------------------------------ |
| RULE_CAUTION_PRINT_LOG | bigInt | Alarm rule, which is programmed to print a log when an alarm is generated. |
| RULE_CAUTION_TRIGGER_CRASH | bigInt | Alarm rule, which is programmed to force the application to exit when an alarm is generated. |
| RULE_THREAD_CHECK_SLOW_PROCESS | bigInt | Caution rule, which is programmed to detect whether any time-consuming function is invoked. |
| RULE_CHECK_ABILITY_CONNECTION_LEAK | bigInt | Caution rule, which is programmed to detect whether ability leakage has occurred. |
| RULE_CAUTION_PRINT_LOG | bigint | Alarm rule, which is programmed to print a log when an alarm is generated. |
| RULE_CAUTION_TRIGGER_CRASH | bigint | Alarm rule, which is programmed to force the application to exit when an alarm is generated. |
| RULE_THREAD_CHECK_SLOW_PROCESS | bigint | Caution rule, which is programmed to detect whether any time-consuming function is invoked. |
| RULE_CHECK_ABILITY_CONNECTION_LEAK | bigint | Caution rule, which is programmed to detect whether ability leakage has occurred. |
## hichecker.addRule
addRule(rule: bigInt): void
addRule(rule: bigint): void
Adds one or more rules. HiChecker detects unexpected operations or gives feedback based on the added rules.
......@@ -39,7 +39,7 @@ Adds one or more rules. HiChecker detects unexpected operations or gives feedbac
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- |
| rule | bigInt | Yes | Rule to be added.|
| rule | bigint | Yes | Rule to be added.|
**Example**
......@@ -54,7 +54,7 @@ hichecker.addRule(
## hichecker.removeRule
removeRule(rule: bigInt): void
removeRule(rule: bigint): void
Removes one or more rules. The removed rules will become ineffective.
......@@ -64,7 +64,7 @@ Removes one or more rules. The removed rules will become ineffective.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- |
| rule | bigInt | Yes | Rule to be removed.|
| rule | bigint | Yes | Rule to be removed.|
**Example**
......@@ -79,7 +79,7 @@ hichecker.removeRule(
## hichecker.getRule
getRule(): bigInt
getRule(): bigint
Obtains a collection of thread, process, and alarm rules that have been added.
......@@ -89,7 +89,7 @@ Obtains a collection of thread, process, and alarm rules that have been added.
| Type | Description |
| ------ | ---------------------- |
| bigInt | Collection of added rules.|
| bigint | Collection of added rules.|
**Example**
......@@ -98,12 +98,12 @@ Obtains a collection of thread, process, and alarm rules that have been added.
hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS);
// Obtain the collection of added rules.
hichecker.getRule(); // Return 1n.
hichecker.getRule(); // return 1n;
```
## hichecker.contains
contains(rule: bigInt): boolean
contains(rule: bigint): boolean
Checks whether the specified rule exists in the collection of added rules. If the rule is of the thread level, this operation is performed only on the current thread.
......@@ -113,13 +113,13 @@ Checks whether the specified rule exists in the collection of added rules. If th
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- |
| rule | bigInt | Yes | Rule to be checked.|
| rule | bigint | Yes | Rule to be checked.|
**Return value**
| Type | Description |
| ------- | ---------------------------------------------------------- |
| boolean | Returns **true** if the rule exists in the collection of added rules; returns **false** otherwise. |
| boolean | Returns **true** if the rule exists in the collection of added rules; returns **false** otherwise.|
**Example**
......@@ -128,6 +128,6 @@ Checks whether the specified rule exists in the collection of added rules. If th
hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS);
// Check whether the added rule exists in the collection of added rules.
hichecker.contains(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // Return true
hichecker.contains(hichecker.RULE_CAUTION_PRINT_LOG); // Return false
hichecker.contains(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // return true;
hichecker.contains(hichecker.RULE_CAUTION_PRINT_LOG); // return false;
```
......@@ -702,7 +702,7 @@ Defines the measurement unit information.
### unitConvert<sup>8+</sup>
unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string
static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string
Converts one measurement unit into another and formats the unit based on the specified locale and style.
......@@ -825,7 +825,7 @@ Obtains the index of a text object.
### isDigit<sup>8+</sup>
isDigit(char: string): boolean
static isDigit(char: string): boolean
Checks whether the input character string is composed of digits.
......@@ -849,7 +849,7 @@ Checks whether the input character string is composed of digits.
### isSpaceChar<sup>8+</sup>
isSpaceChar(char: string): boolean
static isSpaceChar(char: string): boolean
Checks whether the input character is a space.
......@@ -873,7 +873,7 @@ Checks whether the input character is a space.
### isWhitespace<sup>8+</sup>
isWhitespace(char: string): boolean
static isWhitespace(char: string): boolean
Checks whether the input character is a white space.
......@@ -897,7 +897,7 @@ Checks whether the input character is a white space.
### isRTL<sup>8+</sup>
isRTL(char: string): boolean
static isRTL(char: string): boolean
Checks whether the input character is of the right to left (RTL) language.
......@@ -921,7 +921,7 @@ Checks whether the input character is of the right to left (RTL) language.
### isIdeograph<sup>8+</sup>
isIdeograph(char: string): boolean
static isIdeograph(char: string): boolean
Checks whether the input character is an ideographic character.
......@@ -945,7 +945,7 @@ Checks whether the input character is an ideographic character.
### isLetter<sup>8+</sup>
isLetter(char: string): boolean
static isLetter(char: string): boolean
Checks whether the input character is a letter.
......@@ -969,7 +969,7 @@ Checks whether the input character is a letter.
### isLowerCase<sup>8+</sup>
isLowerCase(char: string): boolean
static isLowerCase(char: string): boolean
Checks whether the input character is a lowercase letter.
......@@ -993,7 +993,7 @@ Checks whether the input character is a lowercase letter.
### isUpperCase<sup>8+</sup>
isUpperCase(char: string): boolean
static isUpperCase(char: string): boolean
Checks whether the input character is an uppercase letter.
......@@ -1017,7 +1017,7 @@ Checks whether the input character is an uppercase letter.
### getType<sup>8+</sup>
getType(char: string): string
static getType(char: string): string
Obtains the type of the input character string.
......@@ -1124,7 +1124,7 @@ Obtains the position of the [BreakIterator](#breakiterator8) object in the text
```
var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
breakIter.current(); // 0
iterator.current(); // 0
```
......@@ -1145,7 +1145,7 @@ Puts the [BreakIterator](#breakiterator8) object to the first text boundary, whi
```
var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
breakIter.first(); // 0
iterator.first(); // 0
```
......
# Combination Key
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
>
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module are system APIs and cannot be called by third-party applications.
......@@ -17,66 +18,71 @@ import inputConsumer from '@ohos.multimodalInput.inputConsumer';
## inputConsumer.on
on(type: "key", keyOption: KeyOption, callback: Callback&lt;KeyOption&gt;): void
on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): void
Enables listening for combination key events. When a combination key event that meets the specified conditions occurs, **keyOption** will be passed as an input parameter to **callback**.
Enables listening for combination key events. When a combination key event that meets the specified conditions occurs, **keyOptions** will be passed as an input parameter to **callback**.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters**
| Name | Type | Mandatory | Description |
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the key input event to listen for. Only **key** is supported. |
| keyOption | [KeyOption](#keyoption) | Yes | Key option, which specifies the condition for combination key input. |
| callback | Callback&lt;KeyOption&gt; | Yes | Callback function. When a key input event that meets the specified options occurs, **keyOption** will be passed as an input parameter to **callback**. |
| type | string | Yes| Type of the key input event to listen for. Only **key** is supported.|
| keyOptions | [keyOptions](#keyOptions) | Yes| Key option, which specifies the condition for combination key input.|
| callback | KeyOptions | Yes| Callback used to return the result.<br> When a key input event that meets the specified options occurs, **keyOptions** will be passed as an input parameter to **callback**.|
**Example**
**Example**
```
let keyOption = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function(keyOption) {
console.info("preKeys: " + keyOption.preKeys, "finalKey: " + keyOption.finalKey,
"isFinalKeyDown: " + keyOption.isFinalKeyDown, "finalKeyDownDuration: " + keyOption.finalKeyDownDuration)
let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function(keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
}
inputConsumer.on('key', keyOption, callback);
inputConsumer.on('key', keyOptions, callback);
```
## inputConsumer.off
off(type: "key", keyOption: KeyOption, callback: Callback&lt;KeyOption&gt;): void
off(type: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>): void
Stops listening for combination key events.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters**
| Name | Type | Mandatory | Description |
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the key input event to listen for. Only **key** is supported. |
| keyOption | [KeyOption](#keyoption) | Yes | Key option passed to the key input event when listening starts. |
| callback | Callback&lt;KeyOption&gt; | Yes | Callback function passed to the key input event with the key option when listening starts. |
| type | string | Yes| Type of the key input event to listen for. Only **key** is supported.|
| keyOptions | [keyOptions](#keyOptions) | Yes| Key options passed to the key input event when listening starts.|
| callback | Callback<KeyOptions> | Yes| Callback function passed to the key input event with **keyOptions** when listening starts.|
**Example**
**Example**
```
let keyOption = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function(keyOption) {
console.info("preKeys: " + keyOption.preKeys, "finalKey: " + keyOption.finalKey,
"isFinalKeyDown: " + keyOption.isFinalKeyDown, "finalKeyDownDuration: " + keyOption.finalKeyDownDuration)
let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function(keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
}
inputConsumer.off('key', keyOption, callback);
inputConsumer.off('key', keyOptions, callback);
```
## KeyOption
## keyOptions
Defines the key options that are met when a combination key input event occurs.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
| Name | Type | Mandatory | Description |
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| preKeys | Array | Yes | Array of precedent keys. This parameter can be left empty. There is no requirement on the sequence of precedent keys. |
| finalKey | Number | Yes | Final key in the combination key. This parameter cannot be left blank. |
| isFinalKeyDown | boolean | Yes | Indicates whether the final key is pressed or released. By default, the final key is pressed. |
| finalKeyDownDuration | Number | Yes | Duration for pressing the final key. By default, there is no requirement on the duration. |
| preKeys | Array | Yes| Array of precedent keys. This parameter can be left empty. There is no requirement on the sequence of precedent keys.|
| finalKey | Number | Yes| Final key in the combination key. This parameter cannot be left blank.|
| isFinalKeyDown | boolean | Yes| Whether the final key is pressed or released. By default, the final key is pressed.|
| finalKeyDownDuration | Number | Yes| Duration for pressing the final key. By default, there is no requirement on the duration.|
......@@ -25,8 +25,8 @@ Enables listening for hot swap events of an input device.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | -------------------- |
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------- |
| type | string | Yes | Event type of the input device. |
| listener | Callback&lt;[DeviceListener](#devicelistener<sup>9+</sup>)&gt; | Yes | Listener for events of the input device.|
......@@ -38,10 +38,10 @@ inputDevice.on("change", (data) => {
console.log("type: " + data.type + ", deviceId: " + data.deviceId);
inputDevice.getKeyboardType(data.deviceId, (ret) => {
console.log("The keyboard type of the device is: " + ret);
if (ret == 2 && data.type == 'add') {
if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') {
// The physical keyboard is connected.
isPhysicalKeyboardExist = true;
} else if (ret == 2 && data.type == 'remove') {
} else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') {
// The physical keyboard is disconnected.
isPhysicalKeyboardExist = false;
}
......@@ -60,8 +60,8 @@ Disables listening for hot swap events of an input device.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | -------------------- |
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------- |
| type | string | Yes | Event type of the input device. |
| listener | Callback&lt;[DeviceListener](#devicelistener<sup>9+</sup>)&gt; | No | Listener for events of the input device.|
......@@ -113,7 +113,7 @@ Obtains the IDs of all input devices. This API uses a promise to return the resu
**Return value**
| Parameter | Description |
| ------------------------- | ----------------------------- |
| ---------------------------------- | ------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the result.|
**Example**
......@@ -128,7 +128,7 @@ inputDevice.getDeviceIds().then((ids)=>{
getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): void
Obtains the information about an input device. This API uses an asynchronous callback to return the result.
Obtains information about an input device. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
......@@ -158,14 +158,14 @@ Obtains information about an input device. This API uses a promise to return the
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------------------- |
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------ |
| deviceId | number | Yes | ID of the input device.|
**Return value**
| Parameter | Description |
| -------------------------------------------------- | ----------------------------- |
| ---------------------------------------- | ------------------- |
| Promise&lt;[InputDeviceData](#inputdevicedata)&gt; | Promise used to return the result.|
**Example**
......@@ -181,16 +181,16 @@ inputDevice.getDevice(1).then((inputDevice)=>{
supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;, callback: Callback&lt;Array&lt;boolean&gt;&gt;): void;
Checks whether an input device supports the specified key codes. This API uses an asynchronous callback to return the result.
Obtains the key codes supported by the input device. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
| Name | Type | Mandatory | Description |
| -------- | ------------------------------------ | ---- | --------------------------------- |
| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
| keys | Array&lt;KeyCode&gt; | Yes | Key code to be queried. A maximum of five key codes can be specified. |
| keys | Array&lt;KeyCode&gt; | Yes | Key codes to be queried. A maximum of five key codes can be specified. |
| callback | Callback&lt;Array&lt;boolean&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -206,21 +206,21 @@ inputDevice.supportKeys(1, [17, 22, 2055], (ret)=>{
supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;): Promise&lt;Array&lt;boolean&gt;&gt;;
Checks whether an input device supports the specified key codes. This API uses a promise to return the result.
Obtains the key codes supported by the input device. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------------------------------------ |
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | --------------------------------- |
| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
| keys | Array&lt;KeyCode&gt; | Yes | Key code to be queried. A maximum of five key codes can be specified. |
| keys | Array&lt;KeyCode&gt; | Yes | Key codes to be queried. A maximum of five key codes can be specified. |
**Return value**
| Parameter | Description |
| ----------------------------------- | ----------------------------- |
| ----------------------------------- | ------------------- |
| Promise&lt;Array&lt;boolean&gt;&gt; | Promise used to return the result.|
**Example**
......@@ -242,8 +242,8 @@ Obtains the keyboard type of an input device. This API uses an asynchronous call
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------------------------------- |
| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
| callback | AsyncCallback&lt;[KeyboardType](#keyboardtype)&gt; | Yes | Callback used to return the result. |
......@@ -267,26 +267,26 @@ Obtains the keyboard type of an input device. This API uses a promise to return
**Return value**
| Parameter | Description |
| -------------------------------------------- | ----------------------------- |
| ---------------------------------------- | ------------------- |
| Promise&lt;[KeyboardType](#keyboardtype)&gt; | Promise used to return the result.|
**Example**
```js
// Query the keyboard type of the input device whose ID is 1.
inputDevice.getKeyboardType().then((ret)=>{
inputDevice.getKeyboardType(1).then((ret)=>{
console.log("The keyboard type of the device is: " + ret);
})
```
## DeviceListener<sup>9+</sup>
Defines a listener for events of an input device.
Defines the information about an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description |
| -------- | --------------------------- | ------------------------------------------------------------ |
| -------- | ------------------------- | --------------------------------- |
| type | [ChangeType](#changetype) | Device change type, which indicates whether an input device is inserted or removed. |
| deviceId | number | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
......@@ -297,10 +297,10 @@ Defines the information about an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description |
| -------------------- | -------------------------------------- | ------------------------------------------------------------ |
| id | number | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
| -------------------- | -------------------------------------- | ---------------------------------------- |
| id | number | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes. |
| name | string | Name of the input device. |
| sources | Array&lt;[SourceType](#sourcetype)&gt; | Source types of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad.|
| sources | Array&lt;[SourceType](#sourcetype)&gt; | Source type of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad.|
| axisRanges | Array&lt;[axisRanges](#axisrange)&gt; | Axis information of the input device. |
| bus<sup>9+</sup> | number | Bus type of the input device. |
| product<sup>9+</sup> | number | Product information of the input device. |
......@@ -315,8 +315,8 @@ Defines the axis type of an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type| Description |
| ----------- | -------- | ------------------- |
| Name | Type | Description |
| ----------- | ------ | --------------- |
| touchMajor | string | touchMajor axis. |
| touchMinor | string | touchMinor axis. |
| toolMinor | string | toolMinor axis. |
......@@ -334,7 +334,7 @@ Defines the axis range of an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description |
| ----------------------- | ------------------------- | ---------------- |
| ----------------------- | ------------------------- | -------- |
| source | [SourceType](#sourcetype) | Input source type of the axis.|
| axis | [AxisType](axistype) | Axis type. |
| max | number | Maximum value of the axis. |
......@@ -364,8 +364,8 @@ Defines the change type for the hot swap event of an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type| Description |
| ------ | -------- | ------------------ |
| Name | Type | Description |
| ------ | ------ | --------- |
| add | string | An input device is inserted.|
| remove | string | An input device is removed.|
......@@ -375,11 +375,11 @@ Enumerates the keyboard types.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type| Value | Description |
| ------------------- | -------- | ---- | ------------------ |
| NONE | number | 0 | Keyboard without keys |
| UNKNOWN | number | 1 | Keyboard with unknown keys|
| ALPHABETIC_KEYBOARD | number | 2 | Full keyboard |
| DIGITAL_KEYBOARD | number | 3 | Keypad |
| HANDWRITING_PEN | number | 4 | Stylus |
| REMOTE_CONTROL | number | 5 | Remote control |
| Name | Type | Value | Description |
| ------------------- | ------ | ---- | --------- |
| NONE | number | 0 | Keyboard without keys. |
| UNKNOWN | number | 1 | Keyboard with unknown keys.|
| ALPHABETIC_KEYBOARD | number | 2 | Full keyboard. |
| DIGITAL_KEYBOARD | number | 3 | Keypad. |
| HANDWRITING_PEN | number | 4 | Stylus. |
| REMOTE_CONTROL | number | 5 | Remote control. |
# Input Event
> **NOTE**<br>
> 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.
## Modules to Import
```js
import InputEvent from '@ohos.multimodalInput.inputEvent';
```
**System capability**: SystemCapability.MultimodalInput.Input.Core
**Parameters**
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| id | number | Yes| No| Unique event ID generated by the server.|
| deviceId | number | Yes| No| ID of the device that reports the input event.|
| actionTime | number | Yes| No| Time when the event is reported.|
| screenId | number | Yes| No| ID of the target screen.|
| windowId | number | Yes| No| ID of the target window.|
# Input Event Client
# Key Injection
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
>
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> 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 APIs of this module are system APIs and cannot be called by third-party applications.
> The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import
```
```js
import inputEventClient from '@ohos.multimodalInput.inputEventClient';
```
......@@ -20,38 +20,40 @@ import inputEventClient from '@ohos.multimodalInput.inputEventClient';
injectEvent({KeyEvent: KeyEvent}): void
Injects a key.
Injects a key event.
**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| KeyEvent | [KeyEvent](#keyevent) | Yes| Information about the key to inject.|
| Name | Type | Mandatory | Description |
| -------- | --------------------- | ---- | --------- |
| KeyEvent | [KeyEvent](#keyevent) | Yes | Information about the key event to inject.|
**Example**
```
```js
let keyEvent = {
isPressed: true,
keyCode: 2,
keyDownDuration: 0,
isIntercepted: false
}
res = inputEventClient.injectEvent({KeyEvent: keyEvent});
let res = inputEventClient.injectEvent({KeyEvent: keyEvent});
```
## KeyEvent
Defines the information about the key to inject.
Defines the information about the key event to inject.
**System capability**: SystemCapability.MultimodalInput.Input.InputSimulator
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isPressed | boolean | Yes| Whether the key is pressed.|
| keyCode | Number | Yes| Key code.|
| keyDownDuration | boolean | Yes| Duration for which the key is pressed.|
| isIntercepted | Number | Yes| Whether the key can be intercepted.|
**Parameters**
| Name | Type | Mandatory | Description |
| --------------- | ------- | ---- | --------- |
| isPressed | boolean | Yes | Whether the key is pressed. |
| keyCode | Number | Yes | Key code. |
| keyDownDuration | boolean | Yes | Duration within which the key is pressed. |
| isIntercepted | Number | Yes | Whether the key can be intercepted.|
......@@ -3,6 +3,7 @@
> **NOTE**<br>
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module are system APIs and cannot be called by third-party applications.
......@@ -29,7 +30,8 @@ Enables listening for global touch events.
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------------- |
| type | string | Yes | Type of the input event to listen for. The value is **touch**.|
......@@ -52,7 +54,7 @@ Enables listening for global mouse events.
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------- |
......@@ -73,13 +75,14 @@ inputMonitor.off("mouse", (event) => {
off(type: "touch", receiver?:TouchEventReceiver):void
Enables listening for global touch events.
Stops listening for global touch events.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------------- |
| type | string | Yes | Type of the input event to listen for. The value is **touch**.|
......@@ -99,7 +102,7 @@ Stops listening for global mouse events.
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------- |
......@@ -116,7 +119,7 @@ inputMonitor.off("mouse");
## TouchEventReceiver
Represents the class of the callback used to return the touch event. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the opposite.
This class provides the callback of touch events.
### (touchEvent: TouchEvent): Boolean
......@@ -125,12 +128,14 @@ Represents the callback used to return the touch event. You need to define the n
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
**Parameters**
| Name | Type | Mandatory | Description |
| ---------- | ---------------------------------------- | ---- | ---------------------------------------- |
| touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | Yes | Callback used to return the touch event.|
**Return value**
**Return value**
| Type | Description |
| ------- | -------------------------------------- |
| Boolean | Result indicating whether the touch event has been consumed by the input monitor. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the opposite.|
......
......@@ -28,7 +28,13 @@ Obtains a **MediaLibrary** instance, which is used to access and modify personal
| ----------------------------- | :---- |
| [MediaLibrary](#medialibrary) | **MediaLibrary** instance.|
**Example**
**Example (from API version 9)**
```
var media = mediaLibrary.getMediaLibrary(this.context);
```
**Example (API version 8)**
```
import featureAbility from '@ohos.ability.featureAbility';
......@@ -246,7 +252,7 @@ Creates a media asset. This API uses a promise to return the result.
```
async function example() {
// Create an image file in promise mode
// Create an image file in promise mode.
let mediaType = mediaLibrary.MediaType.IMAGE;
let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE;
const path = await media.getPublicDirectory(DIR_IMAGE);
......@@ -437,13 +443,13 @@ var media = mediaLibrary.getMediaLibrary(context);
media.release()
```
### storeMediaAsset
### storeMediaAsset<sup>(deprecated)</sup>
storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback&lt;string&gt;): void
Stores a media asset. This API uses an asynchronous callback to return the URI that stores the media asset.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
> **NOTE**<br>This API is deprecated since API version 9.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -467,19 +473,19 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option, (err, value) => {
console.log("An error occurred when storing the media asset.");
return;
}
console.log("Media asset stored. ");
console.log("Media asset stored.");
// Obtain the URI that stores the media asset.
});
```
### storeMediaAsset
### storeMediaAsset<sup>(deprecated)</sup>
storeMediaAsset(option: MediaAssetOption): Promise&lt;string&gt;
Stores a media asset. This API uses a promise to return the URI that stores the media asset.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
> **NOTE**<br>This API is deprecated since API version 9.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -512,13 +518,13 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option).then((value) => {
```
### startImagePreview
### startImagePreview<sup>(deprecated)</sup>
startImagePreview(images: Array&lt;string&gt;, index: number, callback: AsyncCallback&lt;void&gt;): void
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **dataability://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
> **NOTE**<br>This API is deprecated since API version 9.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -526,7 +532,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------------------------------- |
| images | Array&lt;string&gt; | Yes | URIs of the images to preview. The value can start with either **https://** or **dataability://**.|
| images | Array&lt;string&gt; | Yes | URIs of the images to preview. The value can start with either **dataability://** or **https://**.|
| index | number | Yes | Index of the first image to preview. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the image preview result. If the preview fails, an error message is returned. |
......@@ -537,7 +543,7 @@ let images = [
"dataability:///media/xxxx/2",
"dataability:///media/xxxx/3"
];
/* Online image usage mode
/* Preview online images.
let images = [
"https://media.xxxx.com/image1.jpg",
"https://media.xxxx.com/image2.jpg"
......@@ -554,13 +560,13 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index, (err) => {
```
### startImagePreview
### startImagePreview<sup>(deprecated)</sup>
startImagePreview(images: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void
Starts image preview. This API can be used to preview local images whose URIs start with **dataability://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the execution result.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
> **NOTE**<br>This API is deprecated since API version 9.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -578,7 +584,7 @@ let images = [
"dataability:///media/xxxx/2",
"dataability:///media/xxxx/3"
];
/* Online image usage mode
/* Preview online images.
let images = [
"https://media.xxxx.com/image1.jpg",
"https://media.xxxx.com/image2.jpg"
......@@ -594,13 +600,13 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, (err) => {
```
### startImagePreview
### startImagePreview<sup>(deprecated)</sup>
startImagePreview(images: Array&lt;string&gt;, index?: number): Promise&lt;void&gt;
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with dataability:// or online images whose URIs start with https://. It uses a promise to return the execution result.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
> **NOTE**<br>This API is deprecated since API version 9.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -608,7 +614,7 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
| Name | Type | Mandatory | Description |
| ------ | ------------------- | ---- | ---------------------------------------- |
| images | Array&lt;string&gt; | Yes | URIs of the images to preview. The value can start with either **https://** or **dataability://**.|
| images | Array&lt;string&gt; | Yes | URIs of the images to preview. The value can start with either **dataability://** or **https://**.|
| index | number | No | Index of the first image to preview. If this parameter is not specified, the default value **0** is used. |
**Return value**
......@@ -624,7 +630,7 @@ let images = [
"dataability:///media/xxxx/2",
"dataability:///media/xxxx/3"
];
/* Online image usage mode
/* Preview online images.
let images = [
"https://media.xxxx.com/image1.jpg",
"https://media.xxxx.com/image2.jpg"
......@@ -639,13 +645,13 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index).then(() => {
```
### startMediaSelect
### startMediaSelect<sup>(deprecated)</sup>
startMediaSelect(option: MediaSelectOption, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
Starts media selection. This API uses an asynchronous callback to return the list of URIs that store the selected media assets.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
> **NOTE**<br>This API is deprecated since API version 9.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -674,13 +680,13 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option, (err, value) => {
```
### startMediaSelect
### startMediaSelect<sup>(deprecated)</sup>
startMediaSelect(option: MediaSelectOption): Promise&lt;Array&lt;string&gt;&gt;
Starts media selection. This API uses a promise to return the list of URIs that store the selected media assets.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
> **NOTE**<br>This API is deprecated since API version 9.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -723,7 +729,7 @@ Provides APIs for encapsulating file asset attributes.
| Name | Type | Readable| Writable| Description |
| ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
| id | number | Yes | No | File asset ID. |
| uri | string | Yes | No | File asset URI, for example, dataability:///media/image/2. |
| uri | string | Yes | No | File asset URI, for example, **dataability:///media/image/2**. |
| mimeType | string | Yes | No | Extended file attributes. |
| mediaType<sup>8+</sup> | [MediaType](#mediatype8) | Yes | No | Media type. |
| displayName | string | Yes | Yes | Display file name, including the file name extension. |
......@@ -821,7 +827,7 @@ async function example() {
commitModify(callback: AsyncCallback&lt;void&gt;): void
Commits the modification of this file asset to the database. This API uses an asynchronous callback to return the result.
Commits the modification in this file asset to the database. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -857,7 +863,7 @@ async function example() {
commitModify(): Promise&lt;void&gt;
Commits the modification of this file asset to the database. This API uses a promise to return the result.
Commits the modification in this file asset to the database. This API uses a promise to return the result.
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -893,6 +899,8 @@ open(mode: string, callback: AsyncCallback&lt;number&gt;): void
Opens this file asset. This API uses an asynchronous callback to return the result.
Note: Currently, the write operations are mutually exclusive. After the write operation is complete, you must call **close** to release the resource.
**Required permissions**: ohos.permission.READ_MEDIA (when **mode** is set to **r**) and ohos.permission.WRITE_MEDIA (when **mode** is set to **w**)
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -901,7 +909,7 @@ Opens this file asset. This API uses an asynchronous callback to return the resu
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ----------------------------------- |
| mode | string | Yes | Mode of opening the file, for example, **r** (read-only), **w** (write-only), and **rw** (read-write).|
| mode | string | Yes | Mode of opening the file, for example, **'r'** (read-only), **'w'** (write-only), and **'rw'** (read-write).|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the file handle. |
**Example**
......@@ -928,6 +936,8 @@ open(mode: string): Promise&lt;number&gt;
Opens this file asset. This API uses a promise to return the result.
Note: Currently, the write operations are mutually exclusive. After the write operation is complete, you must call **close** to release the resource.
**Required permissions**: ohos.permission.READ_MEDIA (when **mode** is set to **r**) and ohos.permission.WRITE_MEDIA (when **mode** is set to **w**)
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -1009,7 +1019,7 @@ close(fd: number): Promise&lt;void&gt;
Closes this file asset. This API uses a promise to return the result.
**Required permissions**: ohos.permission.READ_MEDIA (when **mode** is set to **r**) and ohos.permission.WRITE_MEDIA (when **mode** is set to **w**)
**Required permissions**: ohos.permission.READ_MEDIA (when **mode** is set to **'r'**) and ohos.permission.WRITE_MEDIA (when **mode** is set to **'w'**)
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -1531,7 +1541,7 @@ Checks whether the cursor is in the last row of the result set.
| Type | Description |
| ------- | ---------------------------------- |
| boolean | Returns **true** if the cursor is in the last row of the result set; returns *false** otherwise.|
| boolean | Returns **true** if the cursor is in the last row of the result set; returns *false* otherwise.|
**Example**
......@@ -1566,7 +1576,7 @@ async function example() {
close(): void
Releases and invalidates this **FetchFileResult** instance. Other APIs cannot be invoked after the instance is released.
Releases and invalidates this **FetchFileResult** instance. Other APIs in this instance cannot be invoked after it is released.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
......@@ -1965,7 +1975,7 @@ Provides APIs to implement a physical album.
commitModify(callback: AsyncCallback&lt;void&gt;): void
Commits the modification of the album attributes to the database. This API uses an asynchronous callback to return the result.
Commits the modification in the album attributes to the database. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -2002,7 +2012,7 @@ async function example() {
commitModify(): Promise&lt;void&gt;
Commits the modification of the album attributes to the database. This API uses a promise to return the result.
Commits the modification in the album attributes to the database. This API uses a promise to return the result.
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
......@@ -2204,7 +2214,7 @@ Describes options for fetching media files.
| ----------------------- | ------------------- | ---- | ---- | ---- | ------------------------------------------------------------ |
| selections | string | Yes | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names of the conditions. Example:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?',|
| selectionArgs | Array&lt;string&gt; | Yes | Yes | Yes | Value of the condition, which corresponds to the value of the condition column in **selections**.<br>Example:<br>selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], |
| order<sup>8+</sup> | string | Yes | Yes | No | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " AESC"<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"|
| order | string | Yes | Yes | No | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + " AESC"<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + " DESC"|
| uri<sup>8+</sup> | string | Yes | Yes | No | File URI. |
| networkId<sup>8+</sup> | string | Yes | Yes | No | Network ID of the registered device. |
| extendArgs<sup>8+</sup> | string | Yes | Yes | No | Extended parameters for fetching the files. Currently, no extended parameters are available. |
......@@ -2218,30 +2228,30 @@ Describes the image size.
| width | number | Yes | Yes | Image width, in pixels.|
| height | number | Yes | Yes | Image height, in pixels.|
## MediaAssetOption
## MediaAssetOption<sup>(deprecated)</sup>
Implements the media asset option.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
> **NOTE**<br>This API is deprecated since API version 9.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Mandatory | Description |
| ------------ | ------ | ---- | ---------------------------------------- |
| src | string | Yes | Absolute path of the local file of the application. |
| Name | Type | Mandatory| Description |
| ------------ | ------ | ---- | ------------------------------------------------------------ |
| src | string | Yes | Application sandbox oath of the local file. |
| mimeType | string | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.<br>The value can be 'image/\*', 'video/\*', 'audio/\*' or 'file\*'.|
| relativePath | string | No | Custom path for storing media assets, for example, 'Pictures/'. If this parameter is unspecified, media assets are stored in the default path.<br> Default path of images: 'Pictures/'<br> Default path of videos: 'Videos/'<br> Default path of audios: 'Audios/'<br> Default path of files: 'Documents/'|
## MediaSelectOption
## MediaSelectOption<sup>(deprecated)</sup>
Describes media selection option.
This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
> **NOTE**<br>This API is deprecated since API version 9.
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | -------------------- |
| type | string | Yes | Media type, which can be **image**, **media**, or **video**. Currently, only **media** is supported.|
| count | number | Yes | Number of media assets selected. If **count** is set to **1**, one media asset can be selected. If **count** is greater than **1**, multiple media assets can be selected. |
| count | number | Yes | Number of media assets selected. The value starts from 1, which indicates that one media asset can be selected. |
......@@ -3,7 +3,6 @@
> **NOTE**<br>
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the permission request result.
## Modules to Import
......@@ -12,6 +11,29 @@ Provides the permission request result.
import Ability from '@ohos.application.Ability'
```
## How to Use
The permission request result is obtained through an **AbilityStage** instance.
```js
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
var permissions=['com.example.permission']
var permissionRequestResult;
this.context.requestPermissionsFromUser(permissions,(err,result) => {
if(err){
console.log('requestPermissionsFromUserError: ' + JSON.stringify(err));
}else{
permissionRequestResult=result;
console.log('permissionRequestResult: ' + JSON.stringify(permissionRequestResult));
}
});
}
}
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
# Settings
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
......@@ -23,21 +23,24 @@ Obtains the URI of a data item.
**System capability**: SystemCapability.Applictaions.settings.Core
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
**Parameters**
- Return value
| Type| Description|
| -------- | -------- |
| string | URI of the data item.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
- Example
```typescript
**Return value**
| Type| Description|
| -------- | -------- |
| string | URI of the data item.|
**Example**
```typescript
// Obtain the URI of a data item.
let urivar = settings.getUriSync('settings.screen.brightness');
```
```
## settings.getValueSync
......@@ -48,28 +51,30 @@ Obtains the value of a data item.
**System capability**: SystemCapability.Applictaions.settings.Core
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.|
| name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
| defValue | string | Yes| Default value This parameter is user-defined. If it is not found in the database, the default value is returned.|
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.|
| name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
| defValue | string | Yes| Default value This parameter is user-defined. If it is not found in the database, the default value is returned.|
**Return value**
- Return value
| Type| Description|
| -------- | -------- |
| string | Value of the data item.|
| Type| Description|
| -------- | -------- |
| string | Value of the data item.|
- Example
```typescript
**Example**
```typescript
import featureAbility from '@ohos.ability.featureAbility';
// Obtain the value of 'settings.screen.brightness' (this data item already exists in the database).
let brightness = 'settings.screen.brightness';
let uri = settings.getUriSync(brightness);
let helper = featureAbility.acquireDataAbilityHelper(uri);
let value = settings.getValueSync(helper, brightness, '10');
```
// Obtain the value of 'settings.screen.brightness' (this data item already exists in the database).
let brightness = 'settings.screen.brightness';
let uri = settings.getUriSync(brightness);
let helper = featureAbility.acquireDataAbilityHelper(uri);
let value = settings.getValueSync(helper, brightness, '10');
```
## settings.setValueSync
......@@ -77,32 +82,36 @@ Obtains the value of a data item.
setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean
Sets the value of a data item.
If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database.
**Required permissions**: ohos.permission.WRITE_SYSTEM_SETTING
**System capability**: SystemCapability.Applictaions.settings.Core
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.|
| name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
| value | string | Yes| Value of the data item.|
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.|
| name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
| value | string | Yes| Value of the data item.|
**Return value**
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
| Type| Description|
| -------- | -------- |
| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
- Example
```typescript
**Example**
```typescript
import featureAbility from '@ohos.ability.featureAbility';
// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync
// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync
method will update the value of the data item.)
let brightness = 'settings.screen.brightness';
let uri = settings.getUriSync(brightness);
let helper = featureAbility.acquireDataAbilityHelper(uri);
let ret = settings.setValueSync(helper, brightness, '100');
```
let brightness = 'settings.screen.brightness';
let uri = settings.getUriSync(brightness);
let helper = featureAbility.acquireDataAbilityHelper(uri);
let ret = settings.setValueSync(helper, brightness, '100');
```
\ No newline at end of file
......@@ -6,13 +6,13 @@
## Modules to Import
```js
```
import sms from '@ohos.telephony.sms';
```
## sms.createMessage
createMessage\(pdu: Array<number\>, specification: string, callback: AsyncCallback<ShortMessage\>\): void
createMessage\(pdu: Array&lt;number&gt;, specification: string, callback: AsyncCallback<ShortMessage\>\): void
Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. This API uses an asynchronous callback to return the result.
......@@ -28,7 +28,7 @@ Creates an SMS message instance based on the protocol data unit (PDU) and the sp
**Example**
```js
```
const specification = '3gpp';
// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...].
const pdu = [0x08, 0x91];
......@@ -40,7 +40,7 @@ sms.createMessage(pdu, specification, (err, data) => {
## sms.createMessage
createMessage\(pdu: Array<number\>, specification: string\): Promise<ShortMessage\>
createMessage\(pdu: Array&lt;number&gt;, specification: string\): Promise<ShortMessage\>
Creates an SMS message instance based on the PDU and the specified SMS protocol. This API uses a promise to return the result.
......@@ -61,7 +61,7 @@ Creates an SMS message instance based on the PDU and the specified SMS protocol.
**Example**
```js
```
const specification = '3gpp';
// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...].
const pdu = [0x08, 0x91];
......@@ -91,7 +91,7 @@ Sends an SMS message.
**Example**
```js
```
let sendCallback = function (err, data) {
console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}
......@@ -110,7 +110,7 @@ sms.sendMessage(options);
## sms.getDefaultSmsSlotId<sup>7+</sup>
getDefaultSmsSlotId\(callback: AsyncCallback<number\>\): void
getDefaultSmsSlotId\(callback: AsyncCallback&lt;number&gt;\): void
Obtains the default slot of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result.
......@@ -124,7 +124,7 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use
**Example**
```js
```
sms.getDefaultSmsSlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -133,7 +133,7 @@ sms.getDefaultSmsSlotId((err, data) => {
## sms.getDefaultSmsSlotId<sup>7+</sup>
getDefaultSmsSlotId\(\): Promise<number\>
getDefaultSmsSlotId\(\): Promise&lt;number&gt;
Obtains the default slot of the SIM card used to send SMS messages. This API uses a promise to return the result.
......@@ -143,11 +143,11 @@ Obtains the default slot of the SIM card used to send SMS messages. This API use
| Type | Description |
| --------------- | ------------------------------------------------------------ |
| Promise<number> | Promise used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| Promise&lt;number&gt; | Promise used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Example**
```js
```
let promise = sms.getDefaultSmsSlotId();
promise.then(data => {
console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`);
......@@ -179,7 +179,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
```
let slotId = 0;
let smscAddr = '+861xxxxxxxxxx';
sms.setSmscAddr(slotId, smscAddr, (err,data) => {
......@@ -215,7 +215,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
```
let slotId = 0;
let smscAddr = '+861xxxxxxxxxx';
let promise = sms.setSmscAddr(slotId, smscAddr);
......@@ -248,7 +248,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
```
let slotId = 0;
sms.getSmscAddr(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -282,7 +282,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```js
```
let slotId = 0;
let promise = sms.getSmscAddr(slotId);
promise.then(data => {
......@@ -306,7 +306,7 @@ Checks whether the current device can send and receive SMS messages. This API wo
| ------- | ------------------------------------------------------------ |
| boolean | - **true**: The device can send and receive SMS messages.<br>- **false**: The device cannot send or receive SMS messages.|
```js
```
let result = sms.hasSmsCapability();
console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
```
......@@ -319,7 +319,7 @@ Defines an SMS message instance.
| Name | Type | Description |
| ------------------------ | --------------------------------------- | ------------------------------------------------------------ |
| hasReplyPath | boolean | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>**TP-Reply-Path**: the path in which the mobile phone can reply to the SMS message through the originating SMSC.|
| hasReplyPath | boolean | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>**TP-Reply-Path**: the path in which the device can reply to the SMS message through the originating SMSC.|
| isReplaceMessage | boolean | Whether the received SMS message is a **replace short message**. The default value is **false**.<br>For details, see section 9.2.3.9 in **3GPP TS 23.040**.|
| isSmsStatusReportMessage | boolean | Whether the received SMS message is an SMS delivery status report. The default value is **false**.<br>**SMS-Status-Report**: a message sent from the SMSC to the mobile station to show the SMS message delivery status.|
| messageClass | [ShortMessageClass](#shortmessageclass) | SMS message type. |
......@@ -390,7 +390,7 @@ Provides the callback for the SMS message sending result. Return the SMS deliver
## SendSmsResult
SMS message sending result.
Enumerates SMS message sending results.
**System capability**: SystemCapability.Telephony.SmsMms
......
# System Parameter
> **NOTE**<br>
>
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - This is a system API and cannot be called by third-party applications.
......@@ -49,7 +48,7 @@ try {
get(key: string, callback: AsyncCallback&lt;string&gt;): void
Obtains the value of the attribute with the specified key.
Obtains the value of the attribute with the specified key. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Startup.SysInfo
......@@ -80,7 +79,7 @@ try {
get(key: string, def: string, callback: AsyncCallback&lt;string&gt;): void
Obtains the value of the attribute with the specified key.
Obtains the value of the attribute with the specified key. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Startup.SysInfo
......@@ -89,7 +88,7 @@ Obtains the value of the attribute with the specified key.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.|
| def | string | Yes| Default Value|
| def | string | Yes| Default value.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -113,7 +112,7 @@ try {
get(key: string, def?: string): Promise&lt;string&gt;
Obtains the value of the attribute with the specified key.
Obtains the value of the attribute with the specified key. This API uses a promise to return the result.
**System capability**: SystemCapability.Startup.SysInfo
......@@ -122,7 +121,7 @@ Obtains the value of the attribute with the specified key.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.|
| def | string | No| Default Value|
| def | string | No| Default value.|
**Return value**
......@@ -176,7 +175,7 @@ try {
set(key: string, value: string, callback: AsyncCallback&lt;void&gt;): void
Sets a value for the attribute with the specified key.
Sets a value for the attribute with the specified key. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Startup.SysInfo
......@@ -208,7 +207,7 @@ try {
set(key: string, value: string): Promise&lt;void&gt;
Sets a value for the attribute with the specified key.
Sets a value for the attribute with the specified key. This API uses a promise to return the result.
**System capability**: SystemCapability.Startup.SysInfo
......@@ -217,7 +216,7 @@ Sets a value for the attribute with the specified key.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.|
| value| string | Yes| System attribute value to set.|
| value| string | Yes | System attribute value to set.|
**Return value**
......
......@@ -259,7 +259,7 @@ Removes the first entry in this container.
| -------- | -------- |
| T | Entry removed.|
**Return value**
**Example**
```ts
let treeSet = new TreeSet();
......@@ -281,7 +281,7 @@ Removes the last entry in this container.
| -------- | -------- |
| T | Entry removed.|
**Return value**
**Example**
```ts
let treeSet = new TreeSet();
......
......@@ -158,7 +158,6 @@ Requests the temporary permission for the application to access the USB device.
});
```
## usb.claimInterface
claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number
......@@ -243,14 +242,13 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
console.log(`setConfiguration = ${ret}`);
```
## usb.setInterface
setInterface(pipe: USBDevicePipe, iface: USBInterface): number
Sets a USB interface.
Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and interfaces, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter.
Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and interfaces, call [usb.requestRight](#usbrequestright) to request the device access permission, call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#usbclaiminterface) to claim a USB interface..
**System capability**: SystemCapability.USB.USBManager
......@@ -290,7 +288,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
- **Return value**
| Type| Description|
| -------- | -------- |
| Uint8Array | Raw descriptor data. |
| Uint8Array | Raw descriptor data. The value **undefined** indicates that the operation has failed. |
- **Example**
```js
......@@ -316,7 +314,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
- **Return value**
| Type| Description|
| -------- | -------- |
| number | File descriptor of the USB device. |
| number | File descriptor of the USB device. The value **-1** indicates that the operation has failed. |
- **Example**
```js
......@@ -360,7 +358,7 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim
Performs bulk transfer.
Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and endpoints, call [usb.requestRight](#usbrequestright) to request the device access permission, call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#usbclaiminterface) to claim the USB interface.
Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and endpoints, call [usb.requestRight](#usbrequestright) to request the device access permission, call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#usbclaiminterface) to claim a USB interface.
**System capability**: SystemCapability.USB.USBManager
......@@ -381,7 +379,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
```js
// Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission.
// Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device.
// Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer.
// Call usb.claimInterface to claim a USB interface. After that, call usb.bulkTransfer to start bulk transfer.
usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => {
console.log(`bulkTransfer = ${JSON.stringify(ret)}`);
});
......
......@@ -12,7 +12,8 @@ This module provides WebGL APIs that correspond to the OpenGL ES 2.0 feature set
Create a **<canvas\>** component in the HML file. The following is an example:
```
```html
<!--xxx.hml-->
<div class="container">
<canvas ref="canvas1" style="width : 400px; height : 200px; background-color : lightyellow;"></canvas>
<button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button>
......
......@@ -12,7 +12,8 @@ This module provides WebGL APIs that correspond to the OpenGL ES 3.0 feature set
Create a **<canvas\>** component in the HML file. The following is an example:
```
```html
<!--xxx.hml-->
<div class="container">
<canvas ref="canvas1" style="width : 400px; height : 200px; background-color : lightyellow;"></canvas>
<button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button>
......
......@@ -236,9 +236,7 @@ This API is deprecated since API version 8. You are advised to use [window.creat
create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
Creates a subwindow when the context is [Context](js-apis-Context.md). This API uses an asynchronous callback to return the result.
Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md). This API uses an asynchronous callback to return the result. It is valid since API version 9.
Creates a subwindow (in API version 8) or a system window (since API version 9). This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
......@@ -246,7 +244,7 @@ Creates a system window when the context is [ServiceExtensionContext](js-apis-se
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| ctx | Context | Yes | Current application context.<br>For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).<br>For the definition of **Context** of API version 9, see [Context](js-apis-service-extension-context.md).|
| ctx | Context | Yes | Current application context.<br>For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).<br>For the definition of **Context** of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md). |
| id | string | Yes | Window ID. |
| type | [WindowType](#windowtype) | Yes | Window type. |
| callback | AsyncCallback&lt;[Window](#window)&gt; | Yes | Callback used to return the window created. |
......@@ -270,9 +268,7 @@ Creates a system window when the context is [ServiceExtensionContext](js-apis-se
create(ctx: Context, id: string, type: WindowType): Promise&lt;Window&gt;
Creates a subwindow when the context is [Context](js-apis-Context.md). This API uses a promise to return the result.
Creates a system window when the context is [ServiceExtensionContext](js-apis-service-extension-context.md). This API uses a promise to return the result. It is valid since API version 9.
Creates a subwindow (in API version 8) or a system window (since API version 9). This API uses a promise to return the result.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
......@@ -280,7 +276,7 @@ Creates a system window when the context is [ServiceExtensionContext](js-apis-se
| Name| Type | Mandatory| Description |
| ------ | ------------------------- | ---- | ------------------------------------------------------------ |
| ctx | Context | Yes | Current application context.<br>For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).<br>For the definition of **Context** of API version 9, see [Context](js-apis-service-extension-context.md).|
| ctx | Context | Yes | Current application context.<br>For the definition of **Context** of API version 8, see [Context](js-apis-Context.md).<br>For the definition of **Context** of API version 9, see [ServiceExtensionContext](js-apis-service-extension-context.md). |
| id | string | Yes | Window ID. |
| type | [WindowType](#windowtype) | Yes | Window type. |
......
# Zip Module (JavaScript SDK APIs)
## Constraints
None
## Modules to Import
```javascript
......@@ -9,7 +7,7 @@ import zlib from '@ohos.zlib';
```
## zlib.zipFile
zipFile(inFile:string, outFile:string, options: Options): Promise<void>;
zipFile(inFile:string, outFile:string, options: Options): Promise\<void>
Zips a file. This API uses a promise to return the result.
**System capability**: SystemCapability.BundleManager.Zlib
......@@ -36,17 +34,14 @@ Zips a file. This API uses a promise to return the result.
import zlib from '@ohos.zlib'
var inFile = "/xxx/filename.xxx";
var outFile = "/xxx/xxx.zip";
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION;
options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT;
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY;
var options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
zlib.zipFile(inFile, outFile, options).then((data) => {
if (data == zlib.ErrorCode.ERROR_CODE_OK) {
console.log("zipFile OK");
} else {
console.log("zipFile NG");
}
console.log("zipFile result: " + data);
}).catch((err)=>{
console.log("catch((err)=>" + err);
});
......@@ -60,17 +55,14 @@ zlib.zipFile(inFile, outFile, options).then((data) => {
import zlib from '@ohos.zlib'
var inFile = "/xxx/xxx";
var outFile = "/xxx/xxx.zip";
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION;
options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT;
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY;
zlib.zipFile(inFile , unzipDir, options).then((data) => {
if (data == zlib.ErrorCode.ERROR_CODE_OK) {
console.log("zipFile OK");
} else {
console.log("zipFile NG");
}
var options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
zlib.zipFile(inFile , outFile, options).then((data) => {
console.log("zipFile result: " + data);
}).catch((err)=>{
console.log("catch((err)=>" + err);
});
......@@ -78,7 +70,7 @@ zlib.zipFile(inFile , unzipDir, options).then((data) => {
## zlib.unzipFile
unzipFile(inFile:string, outFile:string, options: Options): Promise<void>;
unzipFile(inFile:string, outFile:string, options: Options): Promise\<void>
Unzips a file. This API uses a promise to return the result.
......@@ -88,7 +80,7 @@ Unzips a file. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| ------- | ----------------------------------- | ---- | ----------------------------------- |
| inFile | string | Yes | Path of the file to unzip. The file name extension is .zip.|
| inFile | string | Yes | Path of the .zip file to unzip.|
| outFile | string | Yes | Path of the unzipped file. |
| options | [Options](#options)| No | Optional parameters for the unzip operation. |
......@@ -106,30 +98,26 @@ import zlib from '@ohos.zlib'
var inFile = "/xx/xxx.zip";
var outFile = "/xxx";
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION;
options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT;
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY;
let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
zlib.unzipFile(inFile, outFile, options).then((data) => {
if (data == zlib.ErrorCode.ERROR_CODE_OK) {
console.log("unzipFile OK");
} else {
console.log("unzipFile NG");
}
console.log("unzipFile result: " + data);
}).catch((err)=>{
console.log("catch((err)=>" + err);
})
```
## options
## Options
| Name | Description |
| --------------------------- | ------------------------------------------------------------ |
| level?: CompressLeve | See [zip.CompressLevel](##zipcompresslevel). |
| memLevel?: MemLevel | See [zip.MemLevel](#zipmemlevel) |
| strategy?: CompressStrategy | See [zip.CompressStrategy](#zipcompressstrategy) |
| level?: CompressLeve | See [zip.CompressLevel](#zipcompresslevel).|
| memLevel?: MemLevel | See [zip.MemLevel](#zipmemlevel). |
| strategy?: CompressStrategy | See [zip.CompressStrategy](#zipcompressstrategy).|
## zip.MemLevel
......@@ -143,24 +131,24 @@ zlib.unzipFile(inFile, outFile, options).then((data) => {
| Name | Description |
| --------------------------------------- | ----------------- |
| COMPRESS_LEVEL_NO_COMPRESSION : 0 | Compress level 0 that indicates uncompressed.|
| COMPRESS_LEVEL_BEST_SPEED : 1 | Compression level 1 that gives the best speed. |
| COMPRESS_LEVEL_BEST_COMPRESSION :9 | Compression level 9 that gives the best compression. |
| COMPRESS_LEVEL_DEFAULT_COMPRESSION : -1| Default compression level. |
| COMPRESS_LEVEL_NO_COMPRESSION: 0 | Compress level 0 that indicates uncompressed.|
| COMPRESS_LEVEL_BEST_SPEED: 1 | Compression level 1 that gives the best speed. |
| COMPRESS_LEVEL_BEST_COMPRESSION: 9 | Compression level 9 that gives the best compression. |
| COMPRESS_LEVEL_DEFAULT_COMPRESSION: -1| Default compression level. |
## Zip.CompressStrategy
| Name | Description |
| -------------------------------------- | ------------------------ |
| COMPRESS_STRATEGY_DEFAULT_STRATEGY : 0 | Default compression strategy. |
| COMPRESS_STRATEGY_FILTERED : 1 | Filtered compression strategy.|
| COMPRESS_STRATEGY_HUFFMAN_ONLY : 2 | Huffman coding compression strategy. |
| COMPRESS_STRATEGY_RLE : 3 | RLE compression strategy. |
| COMPRESS_STRATEGY_FIXED : 4 | Fixed compression strategy. |
| COMPRESS_STRATEGY_DEFAULT_STRATEGY: 0 | Default compression strategy. |
| COMPRESS_STRATEGY_FILTERED: 1 | Filtered compression strategy.|
| COMPRESS_STRATEGY_HUFFMAN_ONLY: 2 | Huffman coding compression strategy. |
| COMPRESS_STRATEGY_RLE: 3 | RLE compression strategy. |
| COMPRESS_STRATEGY_FIXED: 4 | Fixed compression strategy. |
## zip.ErrorCode
| Name | Description |
| -------------------- | ------------ |
| ERROR_CODE_OK: 0 | The API is successfully called.|
| ERROR_CODE_ERRNO:- 1 | Failed to call the API.|
| ERROR_CODE_ERRNO: -1| Failed to call the API.|
# Universal Events
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br>
> Universal events are supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.
## Event Description
......@@ -13,23 +13,23 @@
Different from private events, universal events can be bound to most components.
| Name | Parameter | Name | Support Bubbling |
| ------------------------ | ---------- | ---------------------------------------- | -------------- |
| touchstart | TouchEvent | Triggered when the tapping starts.<br>> **Note**: For details about **TouchEvent**, see Table 2.| Yes<sup>5+</sup>|
| touchmove | TouchEvent | Triggered when the tapping moves. | Yes<sup>5+</sup>|
| touchcancel | TouchEvent | Triggered when the tapping is interrupted. | Yes<sup>5+</sup>|
| touchend | TouchEvent | Triggered when the tapping ends. | Yes<sup>5+</sup>|
| click | - | Triggered when a component is clicked. | Yes<sup>6+</sup>|
| doubleclick<sup>7+</sup> | - | Triggered when a component is double-clicked. | No<br>**Note**: Bubbling is supported since API version 9.|
| longpress | - | Triggered when a component is long pressed. | No<br>**Note**: Bubbling is supported since API version 9.|
| swipe<sup>5+</sup> | SwipeEvent | Triggered when a user quickly swipes on a component.<br>> **Note**: For details about **SwipeEvent**, see Table 6.| No<br>**Note**: Bubbling is supported since API version 9.|
| Name | Parameter | Description | Support Bubbling |
| ------------------------ | ---------- | ---------------------------------------- | ---------------------------------------- |
| touchstart | TouchEvent | Triggered when the tapping starts. For details about **TouchEvent**, see Table 2. | Yes<sup>5+</sup> |
| touchmove | TouchEvent | Triggered when the tapping moves. | Yes<sup>5+</sup> |
| touchcancel | TouchEvent | Triggered when the tapping is interrupted. | Yes<sup>5+</sup> |
| touchend | TouchEvent | Triggered when the tapping ends. | Yes<sup>5+</sup> |
| click | - | Triggered when a component is clicked. | Yes<sup>6+</sup> |
| doubleclick<sup>7+</sup> | - | Triggered when a component is double-clicked. | No<br>Bubbling is supported since API version 9. |
| longpress | - | Triggered when a component is long pressed. | No<br>Bubbling is supported since API version 9.|
| swipe<sup>5+</sup> | SwipeEvent | Triggered when a user quickly swipes on a component.<br/>For details about **SwipeEvent**, see Table 4. | No<br>Bubbling is supported since API version 9.|
| attached<sup>6+</sup> | - | Triggered after the current component node is mounted to the render tree. | No |
| detached<sup>6+</sup> | - | Triggered when the current component node is removed from the render tree. | No |
| pinchstart<sup>7+</sup> | PinchEvent | Triggered when a pinch operation is started.<br>> **Note**: For details about **PinchEvent**, see Table 7.| No |
| pinchstart<sup>7+</sup> | PinchEvent | Triggered when a pinch operation is started.<br>For details about **PinchEvent**, see Table 5.| No |
| pinchupdate<sup>7+</sup> | PinchEvent | Triggered when a pinch operation is in progress. | No |
| pinchend<sup>7+</sup> | PinchEvent | Triggered when a pinch operation is ended. | No |
| pinchcancel<sup>7+</sup> | PinchEvent | Triggered when a pinch operation is interrupted. | No |
| dragstart<sup>7+</sup> | DragEvent | Triggered when dragging starts.<br>> **Note**: For details about **DragEvent**, see Table 8 .| No |
| dragstart<sup>7+</sup> | DragEvent | Triggered when dragging starts.<br>For details about **DragEvent**, see Table 6. | No |
| drag<sup>7+</sup> | DragEvent | Triggered when dragging is in progress. | No |
| dragend<sup>7+</sup> | DragEvent | Triggered when dragging is ended. | No |
| dragenter<sup>7+</sup> | DragEvent | Triggered when the dragged component enters a drop target. | No |
......@@ -38,22 +38,24 @@ Different from private events, universal events can be bound to most components.
| drop<sup>7+</sup> | DragEvent | Triggered when the dragged component is dropped on a drop target. | No |
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> Events not listed in the preceding table are non-bubbling events, such as the [change event](../arkui-js/js-components-basic-input.md#events). For details, see the specific component.
> **NOTE**<br>
> Events not listed in the preceding table do not support bubbling, such as the [change event](../arkui-js/js-components-basic-input.md#events) of the **<input\>** component. For details, see the description of the specific component.
**Table 1** BaseEvent
| Attribute | Type | Description |
| --------- | ------ | --------------------------- |
| --------------------- | -------------------- | --------------------------- |
| type | string | Event type, such as **click** and **longpress**.|
| timestamp | number | Timestamp when the event is triggered. |
| deviceId<sup>6+</sup> | number | ID of the device that triggers the event. |
| target<sup>6+</sup> | [Target](#target6)| Target object that triggers the event. |
**Table 2** TouchEvent (inherited from BaseEvent)
| Attribute | Type | Description |
| -------------- | ---------------------- | ---------------------------------------- |
| touches | Array&lt;TouchInfo&gt; | Attribute set of the touch event, including the information array of the touch points on the screen. |
| changedTouches | Array&lt;TouchInfo&gt; | Attribute set when a touch event occurs, including the information array of changed touch points on the screen. **changedTouches** has the same data format as **touches** and indicates touch point changes, such as from no touch point to newly generated touch points, from some touch points to no touch point, and location changes. For example, when the user's finger leaves the touchscreen, no data exists in the **touches** array, but **changedTouches** will save the generated data.|
| changedTouches | Array&lt;TouchInfo&gt; | Attribute set when a touch event occurs, including the information array of changed touch points on the screen. **changedTouches** has the same data format as **touches** and indicates touch point changes, including changes in the number and location of touch points. For example, when the user's finger leaves the screen, which means that the number of touch points changes from 1 to 0, **changedTouches** has the relevant data generated, but not **touches**.|
**Table 3** TouchInfo
......@@ -70,7 +72,7 @@ Different from private events, universal events can be bound to most components.
| Attribute | Type | Description |
| --------------------- | ------ | ---------------------------------------- |
| direction | string | Swiping direction. The value can be one of the following:<br>1. **left**: Swipe from right to left.<br>2. **right**: Swipe from left to right.<br>3. **up**: Swipe upwards.<br>4. **down**: Swipe downwards.|
| direction | string | Swiping direction. The value can be one of the following:<br>- **left**: Swipe left.<br>- **right**: Swipe right.<br>- **up**: Swipe up.<br>- **down**: Swipe down.|
| distance<sup>6+</sup> | number | Swiping distance in the swiping direction. |
**Table 5** PinchEvent<sup>7+</sup>
......@@ -84,33 +86,32 @@ Different from private events, universal events can be bound to most components.
**Table 6** DragEvent<sup>7+</sup> (inherited from BaseEvent)
| Attribute | Type | Description |
| --------- | ------ | ---------------- |
| ------------------------- | -------------------------------- | ---------------- |
| type | string | Event name. |
| globalX | number | Horizontal distance from the upper left corner of the screen, which acts as the origin of coordinates.|
| globalY | number | Vertical distance from the upper left corner of the screen, which acts as the origin of coordinates.|
| timestamp | number | Timestamp. |
| dataTransfer<sup>9+</sup> | [DataTransfer](#datatransfer9)| Object for data transfer. |
## Event Object
## Target<sup>6+</sup>
When a component triggers an event, the event callback receives an event object by default. You can obtain the corresponding information through the event object.
**target object**
| Attribute | Type | Description |
| -------------------- | ------ | ---------------------------------------- |
| dataSet<sup>6+</sup> | Object | Custom attribute set defined through [data-*](../arkui-js/js-components-common-attributes.md).|
**Example**
```
```html
<!-- xxx.hml -->
<div>
<div data-a="dataA" data-b="dataB"
style="width: 100%; height: 50%; background-color: saddlebrown;"@touchstart='touchstartfunc'></div>
</div>
```
```
```js
// xxx.js
export default {
touchstartfunc(msg) {
......@@ -119,3 +120,147 @@ export default {
}
}
```
## DataTransfer<sup>9+</sup>
Use **dataTransfer** to transfer data during the drag operation, so you can perform operations on the data when the drag operation is complete.
### setData<sup>9+</sup>
setData(key: string, value: object): boolean
Sets the data associated with the specified key. If there is no data associated with the key, the data will be appended. If there is already data associated with the key, the data will replace the existing data in the same position.
**Parameters**
| Name | Type | Mandatory | Name |
| ----- | ------ | ---- | ------- |
| key | string | Yes | Data key. |
| value | object | Yes | Data to be stored.|
**Return value**
| Type | Description |
| ------- | ------------------------ |
| boolean | Operation result. The value **true** means that the operation is successful, and **false** means otherwise.|
**Example**
```js
// value in setData can be of a primitive type.
dragStart(e) {
var isSetOk = e.dataTransfer.setData('name', 1);
},
// value in setData can be of the object type.
dragStart(e) {
var person = new Object();
person.name = "tom";
person.age = 21;
var isSetOk = e.dataTransfer.setData('person', person);
}
```
### getData<sup>9+</sup>
getData(key: string): object
Obtains the data associated with the specified key. If no data is associated with the key, an empty string will be returned.
**Parameters**
| Name | Type | Mandatory | Name |
| ---- | ------ | ---- | ----- |
| key | string | Yes | Data key.|
**Return value**
| Type | Description |
| ------ | ------ |
| object | Obtained data.|
**Example**
```js
dragStart(e) {
var person = new Object();
person.name = "tom";
person.age = 21;
e.dataTransfer.setData('person', person);
},
dragEnd(e){
var person = e.dataTransfer.getData('person');
},
```
### clearData<sup>9+</sup>
clearData(key?: string): boolean
Deletes data associated with the specified key. If there is no data associated with the key, this API will not have any effect.
If the key is null, all data will be deleted.
**Parameters**
| Name | Type | Mandatory | Name |
| ---- | ------ | ---- | ----- |
| key | string | No | Data key.|
**Return value**
| Type | Description |
| ------- | ------------------------ |
| boolean | Operation result. The value **true** means that the operation is successful, and **false** means otherwise.|
**Example**
```js
dragEnd(e) {
var isSuccess = e.dataTransfer.clearData('name');
}
```
### setDragImage<sup>9+</sup>
setDragImage(pixelmap: PixelMap, offsetX: number,offsetY: number): boolean
Sets a custom drag image.
**Parameters**
| Name | Type | Mandatory | Name |
| -------- | -------- | ---- | ---------------------------------------- |
| pixelmap | PixelMap | Yes | Image transferred from the frontend. For details, see [PixelMap](../apis/js-apis-image.md#pixelmap7).|
| offsetX | number | Yes | Horizontal offset relative to the image. |
| offsetY | number | Yes | Vertical offset relative to the image. |
**Return value**
| Type | Description |
| ---- | ------------------------ |
| bool | Operation result. The value **true** means that the operation is successful, and **false** means otherwise.|
**Example**
```js
createPixelMap() {
let color = new ArrayBuffer(4*96*96);
var buffer = new Uint8Array(color);
for (var i = 0; i < buffer.length; i++) {
buffer[i] = (i + 1) % 255;
}
let opts = {
alphaType:0,
editable:true,
pixelFormat:4,
scaleMode:1,
size:{height:96,width:96}
}
const promise = image.createPixelMap(color,opts);
promise.then((data)=> {
console.error('-create pixmap has info message:' + JSON.stringify(data));
this.pixelMap = data;
this.pixelMapReader = data;
})
},
onInit() {
this.createPixelMap
},
dragStart(e) {
e.dataTransfer.setDragImage(this.pixelMapReader, 50, 50);
}
```
# Custom Dialog Box
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
> This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
......@@ -20,8 +20,9 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, au
| cancel | () =&gt; void | No | - | Callback invoked when the dialog box is closed after the overlay exits. |
| autoCancel | boolean | No | true | Whether to allow users to click the overlay to exit. |
| alignment | DialogAlignment | No | DialogAlignment.Default | Alignment mode of the dialog box in the vertical direction. |
| offset | {<br/>dx: Length \|[Resource](../../ui/ts-types.md#resource),<br/>dy: Length \|[Resource](../../ui/ts-types.md#resource)<br/>} | | | Offset of the dialog box relative to the alignment position. |
| offset | {<br/>dx: Length \|[Resource](../../ui/ts-types.md#resource),<br/>dy: Length \|[Resource](../../ui/ts-types.md#resource)<br/>} | No | - | Offset of the dialog box relative to the alignment position. |
| customStyle | boolean | No | false | Whether the style of the dialog box is customized. |
| gridCount<sup>8+</sup> | number | No | - | Count of grid columns occupied by the dialog box. |
- DialogAlignment enums
| Name | Description |
......@@ -38,7 +39,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, au
| BottomEnd<sup>8+</sup> | Bottom right alignment. |
### CustomDialogController
## CustomDialogController
### Objects to Import
......@@ -48,17 +49,14 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, au
dialogController : CustomDialogController = new CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, autoCancel?: boolean})
```
### dialogController.open
### open()
open(): void
Opens the content of the custom dialog box. If the content has been displayed, this API does not take effect.
### dialogController.close
### close
close(): void
Closes the custom dialog box. If the dialog box is closed, the setting does not take effect.
......@@ -67,7 +65,8 @@ Closes the custom dialog box. If the dialog box is closed, the setting does not
## Example
```
```ts
// xxx.ets
@CustomDialog
struct CustomDialogExample {
controller: CustomDialogController
......
# Menu
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
> **NOTE**<br>The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
## ContextMenu.close
|methods|description|
|Method|Description|
|----|---|
|close(): void|Closes the menu bound to this component through [bindContextMenu](./ts-universal-attributes-menu.md#Atrributes) on a page.|
- Example
```
@Entry
```
// xxx.ets
@Entry
@Component
struct Index {
@Builder MenuBuilder(){
......@@ -35,4 +35,4 @@
.height('100%')
}
}
```
```
......@@ -3,6 +3,7 @@
- Access Control
- [Access Control Overview](accesstoken-overview.md)
- [Access Control Development](accesstoken-guidelines.md)
- [Permission List](permission-list.md)
- User Authentication
- [User Authentication Overview](userauth-overview.md)
- [User Authentication Development](userauth-guidelines.md)
......
......@@ -3,14 +3,14 @@
## Introduction
AccessTokenManager (ATM) implements unified app permission management based on access tokens on OpenHarmony.
By default, apps can access limited system resources. However, in some cases, an app needs to access excess data (including personal data) and functions of the system or another app to implement extended functions. Systems or apps must also share their data or functions through interfaces in an explicit manner. OpenHarmony uses app permissions to perform access control and prevent improper or malicious use of these data or functions.
By default, apps can access limited system resources. However, in some cases, an app needs to access excess data (including personal data) and functions of the system or another app to implement extended functions. The system or apps must also share their data or functions through interfaces in an explicit manner. OpenHarmony uses app permissions to perform access control and prevent improper or malicious use of these data or functions.
App permissions are used to protect the following objects:
- Data: personal data (such as photos, Contacts, calendar, and location), device data (such as device ID, camera, and microphone), and app data.
- Data: personal data (such as photos, contacts, calendar, and location), device data (such as device ID, camera, and microphone), and app data.
- Functions: device functions (such as making calls, sending SMS messages, and connecting to the Internet) and app functions (such as displaying windows and creating shortcuts).
Without the required permissions, an app cannot access or perform operations on the target object. Permissions must be clearly defined for apps. With app permissions, the system can standardize the behavior of apps and protect user privacy. Before an app accesses the target object, the target object verifies the app's permissions and denies the access if the app does not have required permissions.
Without the required permissions, an app cannot access or perform operations on the target object. Permissions must be clearly defined for apps. With well-defined app permissions, the system can standardize the behavior of apps and protect user privacy. Before an app accesses the target object, the target object verifies the app's permissions and denies the access if the app does not have required permissions.
Currently, ATM performs app permission verification based on the token identity (Token ID). A token ID identifies an app. The ATM manages app permissions based on the app's token ID.
......@@ -36,25 +36,25 @@ The following describes two common scenarios.
Video playback apps need to use multimedia functions and read and write media files stored on storage devices. Therefore, the apps must have at least the following permissions:
* ohos.permission.READ_MEDIA (allowing the app to read external media files)
* ohos.permission.READ_MEDIA (allowing the apps to read external media files)
* ohos.permission.WRITE_MEDIA (allowing the app to read and write external media files)
* ohos.permission.WRITE_MEDIA (allowing the apps to read and write external media files)
- **Photography apps**
Photography apps need to use the camera function. Before accessing the camera service, the app must have the following permission:
Photography apps need to use the camera function. Before accessing the camera service, the apps must have the following permission:
ohos.permission.CAMERA (allowing the app to use the camera to take photos and record videos).
ohos.permission.CAMERA (allowing the apps to use the camera to take photos and record videos)
### Basic Principles
Observe the following principles for permission management:
- Provide clear description about the app functions and scenarios and permissions required for using the app so that users can clearly know why, when, and how to apply for permissions for using the app. Do not induce or mislead users' authorization. The permissions on an app must comply with the description provided in the app.
- Provide clear description about the app functions and scenarios for each permission required by the app so that users can clearly know why and when these permissions are required. Do not induce or mislead users' authorization. The permissions on an app must comply with the description provided in the app.
- Use the principle of least authority for user permissions. Allow only necessary permissions for service functions.
- When an app is started for the first time, avoid frequently displaying pop-up windows for users to apply for multiple permissions. Allow users to apply for permissions only when they need to use the corresponding service functions.
- When an app is started for the first time, avoid frequently displaying dialog boxes to request permissions. Allow the app to apply for permissions only when it needs to use the corresponding service functions.
- If a user rejects to authorize a permission, the user can still use functions irrelevant to this permission and can register and access the app.
- Provide no more message if a user rejects the authorization required by a function. Provide onscreen instructions to direct the user to give authorization in System Settings if the user triggers this function again or needs to use this function.
- Provide no more message if a user rejects the authorization required by a function. Provide onscreen instructions to direct the user to grant the permission in **Settings** if the user triggers this function again or needs to use this function.
- All the permissions granted to apps must come from the Permission List. Custom permissions are not allowed for apps currently.
......@@ -74,10 +74,7 @@ The table below describes the APLs.
| system_basic| The apps of this level provide basic system services. |
| Normal | The apps of this level are normal apps. |
By default, apps are of the normal APL. To declare the system_basic or higher APL:
- The APL must be approved by the app store.
- The APL must be declared in the **apl** field of the app's profile in the app installation package, and a profile signing certificate must be generated. For details, see [Configuring OpenHarmony App Signature Information]( https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-debugging-and-running-0000001263040487#section17660437768).
By default, apps are of the normal APL. For the app of the system_basic or system_core APL, declare the app APL level in the **apl** field in the app's profile, and use the profile signing tool to generate a certificate when developing the app installation package. For details about the signing process, see [Hapsigner Guide](hapsigntool-guidelines.md).
### Permission Levels
The permissions open to apps vary with the permission level. The permission levels include the following in ascending order of seniority.
......@@ -120,7 +117,7 @@ Permissions can be classified into the following types based on the authorizatio
The app permissions are authorized by the system. This type of apps cannot access user or device sensitive information. The allowed operations have minor impact on the system or other apps.
For a system_grant app, the system automatically grants the required permissions to the app when the app is installed. The system_grant permission list must be presented to users on the details page of the app store.
For a system_grant app, the system automatically grants the required permissions to the app when the app is installed. The system_grant permission list must be presented to users on the details page of the app in the app store.
- **user_grant**
......@@ -128,15 +125,13 @@ Permissions can be classified into the following types based on the authorizatio
This type of permissions must be declared in the app installation package and authorized by users dynamically during the running of the app. The app has the permission only after user authorization.
For example, in the [Permission List](#permission-list), the permissions for the microphone and camera are user_grant permissions. The list provides reasons for using the permissions.
For example, in the [Permission List](permission-list.md), the permissions for the microphone and camera are user_grant. The list provides reasons for using the permissions.
The user_grant permission list must also be presented on the details page of the app store.
The user_grant permission list must also be presented on the details page of the app in the app store.
## Authorization Processes
The process for an app obtaining the required permissions varies
depending on the permission authorization mode.
The process for an app obtaining the required permissions varies depending on the permission authorization mode.
- For a system_grant permission, you need to [declare the permission](accesstoken-guidelines.md) in the **config.json** file. The permission will be pre-granted when the app is installed.
......@@ -150,7 +145,7 @@ The procedure is as follows:
2. Associate the object that requires the permissions in the app with the target permissions. In this way, the user knows the operations to be granted with the specified permissions.
3. Check whether the user has granted the required permissions to the app when the app is running. If yes, the app can access the data or perform the operation. If the user has not granted the permissions to the app, display a dialog box requesting the user authorization when the app attempts to access the data or perform the operation.
3. Check whether the user has granted the required permissions to the app when the app is running. If yes, the app can access the data or perform the operation. If the user has not granted the permissions to the app, display a dialog box requesting the user authorization when the app attempts to access the data.
4. Check the user authorization result. Allow the next step only after the user has granted the permissions to the app.
......@@ -158,7 +153,7 @@ The procedure is as follows:
- Check the app's permission each time before the operation requiring the permission is performed.
- To check whether a user has granted specific permissions to your app, use the [verifyAccessToken](../reference/apis/js-apis-abilityAccessCtrl.md) method. This method returns [PERMISSION_GRANTED](../reference/apis/js-apis-abilityAccessCtrl.md) or [PERMISSION_DENIED](../reference/apis/js-apis-abilityAccessCtrl.md). For details about the sample code, see [Access Control Development](accesstoken-guidelines.md).
- To check whether a user has granted specific permissions to your app, use the [verifyAccessToken](../reference/apis/js-apis-abilityAccessCtrl.md#verifyaccesstoken) method. This method returns [PERMISSION_GRANTED](../reference/apis/js-apis-abilityAccessCtrl.md#grantstatus) or [PERMISSION_DENIED](../reference/apis/js-apis-abilityAccessCtrl.md#grantstatus). For details about the sample code, see [Access Control Development](accesstoken-guidelines.md).
- Users must be able to understand and control the authorization of user_grant permissions. During the running process, the app requiring user authorization must proactively call the API to dynamically request the authorization. Then, the system displays a dialog box asking the user to grant the requested permission. The user will determine whether to grant the permission based on the running context of the app.
- The permission authorized is not permanent, because the user may revoke the authorization at any time. Therefore, even if the user has granted the requested permission to the app, the app must check for the permission before calling the API controlled by this permission.
......@@ -166,107 +161,10 @@ The procedure is as follows:
If the permission required by an app has higher level than the app's APL, you can use the ACL to grant the permissions required.
In addition to the preceding [authorization processes](#authorization-processes), you need to declare the ACL.
In addition to the preceding [authorization processes](#authorization-processes), you must declare the ACL.
In addition to declaring the required permissions in the **config.json** file, you must declare the high-level permissions in the app's [profile](accesstoken-guidelines.md). The subsequent steps remain unchanged.
In other words, in addition to declaring the required permissions in the **config.json** file, you must declare the high-level permissions in the app's [profile](accesstoken-guidelines.md). The subsequent steps of authorization are the same.
**NOTE**
* The ACL must be approved by the app store.
* Declare the target ACL in the **acl** field of the app's profile in the app installation package, and generate a profile signing certificate. For details, see [Configuring OpenHarmony App Signature Information]( https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-debugging-and-running-0000001263040487#section17660437768).
## Permission List
The following lists the permissions defined by the system.
| Permission | APL | Authorization Mode | Enable ACL| Description |
| -------------------------------------------------------- | ------------ | ------------ | ------- | ------------------------------------------------------------ |
| ohos.permission.USE_BLUETOOTH | normal | system_grant | TRUE | Allows an app to access to Bluetooth configuration. |
| ohos.permission.DISCOVER_BLUETOOTH | normal | system_grant | TRUE | Allows an app to configure Bluetooth on a device, initiate or cancel a scan for Bluetooth devices, and pair with Bluetooth devices. |
| ohos.permission.MANAGE_BLUETOOTH | system_basic | system_grant | TRUE | Allows an app to pair with a Bluetooth device and access the Contacts or messages of the device. |
| ohos.permission.INTERNET | normal | system_grant | TRUE | Allows an app to access the Internet. |
| ohos.permission.MODIFY_AUDIO_SETTINGS | normal | system_grant | TRUE | Allows an app to modify audio settings. |
| ohos.permission.GET_TELEPHONY_STATE | system_basic | system_grant | TRUE | Allows an app to read telephony information. |
| ohos.permission.REQUIRE_FORM | system_basic | system_grant | TRUE | Allows an app to obtain the Ability Form. |
| ohos.permission.GET_NETWORK_INFO | normal | system_grant | TRUE | Allows an app to obtain network information. |
| ohos.permission.PLACE_CALL | system_basic | system_grant | TRUE | Allows an app to make calls without starting the dialer. |
| ohos.permission.SET_NETWORK_INFO | normal | system_grant | TRUE | Allows an app to set data network information. |
| ohos.permission.REMOVE_CACHE_FILES | system_basic | system_grant | TRUE | Allows the cache of the specified app to be cleared. |
| ohos.permission.REBOOT | system_basic | system_grant | TRUE | Allows an app to restart the device. |
| ohos.permission.RUNNING_LOCK | normal | system_grant | TRUE | Allows an app to obtain a running lock. |
| ohos.permission.ENROLL_BIOMETRIC | system_core | system_grant | FALSE | Allows an app to add or remove biometric data. |
| ohos.permission.ACCESS_BIOMETRIC | normal | system_grant | FALSE | Allows an app to use biometric recognition for identity authentication. |
| ohos.permission.ACCESS_BIOMETRIC_INTERNAL | system_core | system_grant | FALSE | Allows an app to apply for or release biometric recognition resources. |
| ohos.permission.RESET_BIOMETRIC_LOCKOUT | system_core | system_grant | FALSE | Allows an app to reset the maximum number of failures allowed before biometric authentication is locked. |
| ohos.permission.SET_TIME | system_basic | system_grant | TRUE | Allows an app to set the system time. |
| ohos.permission.SET_TIME_ZONE | system_basic | system_grant | TRUE | Allows an app to set the system time zone. |
| ohos.permission.DOWNLOAD_SESSION_MANAGER | system_core | system_grant | TRUE | Allows an app to manage the downloaded sessions. |
| ohos.permission.COMMONEVENT_STICKY | normal | system_grant | TRUE | Allows an app to publish sticky common events. |
| ohos.permission.SYSTEM_FLOAT_WINDOW | normal | system_grant | TRUE | Allows an app to be displayed in a floating window on top of other apps. |
| ohos.permission.POWER_MANAGER | system_core | system_grant | TRUE | Allows an app to hibernate or wake up the device by calling APIs. |
| ohos.permission.REFRESH_USER_ACTION | system_basic | system_grant | TRUE | Allows an app to reset the screen timeout counter when a user input event occurs, such as pressing a key or tapping the screen. |
| ohos.permission.POWER_OPTIMIZATION | system_basic | system_grant | TRUE | Allows an app to set power saving mode, obtain configuration of the power saving mode, and receive notifications of the configuration changes.|
| ohos.permission.REBOOT_RECOVERY | system_basic | system_grant | TRUE | Allows an app to restart the device and enter Recovery mode. |
| ohos.permission.MANAGE_LOCAL_ACCOUNTS | system_basic | system_grant | TRUE | Allows an app to manage local user accounts. |
| ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | system_basic | system_grant | TRUE | Allows access between multiple OS accounts. |
| ohos.permission.VIBRATE | normal | system_grant | TRUE | Allows an app to control motor vibration. |
| ohos.permission.CONNECT_IME_ABILITY | system_core | system_grant | TRUE | Allows an app or service to bind the **InputMethodAbility**. |
| ohos.permission.CONNECT_SCREEN_SAVER_ABILITY | system_core | system_grant | TRUE | Allows an app or service to bind the **ScreenSaverAbility**. |
| ohos.permission.READ_SCREEN_SAVER | system_basic | system_grant | TRUE | Allows an app to read the screen saver information, such as the list of screen savers that have been installed and the activated one. |
| ohos.permission.WRITE_SCREEN_SAVER | system_basic | system_grant | TRUE | Allows an app to modify the screen saver information, such as activating and previewing a screen saver. |
| ohos.permission.SET_WALLPAPER | normal | system_grant | TRUE | Allows an app to set a static wallpaper. |
| ohos.permission.GET_WALLPAPER | system_basic | system_grant | TRUE | Allows an app to read wallpaper files. |
| ohos.permission.CHANGE_ABILITY_ENABLED_STATE | system_basic | system_grant | TRUE | Allows an app to enable or disable an app or component. |
| ohos.permission.ACCESS_MISSIONS | system_basic | system_grant | TRUE | Allows an app to obtain information about running processes and tasks in a task stack. |
| ohos.permission.CLEAN_BACKGROUND_PROCESSES | normal | system_grant | TRUE | Allows an app to clear background processes based on their bundle names. |
| ohos.permission.KEEP_BACKGROUND_RUNNING | normal | system_grant | TRUE | Allows a service ability to keep running in the background. |
| ohos.permission.UPDATE_CONFIGURATION | system_basic | system_grant | TRUE | Allows an app to modify system settings. |
| ohos.permission.GRANT_SENSITIVE_PERMISSIONS | system_core | system_grant | TRUE | Allows an app to grant sensitive permissions to other apps. |
| ohos.permission.REVOKE_SENSITIVE_PERMISSIONS | system_core | system_grant | TRUE | Allows an app to revoke sensitive permissions granted to other apps. |
| ohos.permission.GET_SENSITIVE_PERMISSIONS | system_core | system_grant | TRUE | Allows an app to obtain the sensitive permissions that have been granted to other apps. |
| ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION | system_core | system_grant | TRUE | Allows an app to set the attributes of apps of other users. |
| ohos.permission.LISTEN_BUNDLE_CHANGE | system_basic | system_grant | TRUE | Allows an app to listen for changes in other apps, when they are installed, updated, or uninstalled. |
| ohos.permission.GET_BUNDLE_INFO | normal | system_grant | TRUE | Allows a non-system app to obtain information about other apps. |
| ohos.permission.ACCELEROMETER | normal | system_grant | TRUE | Allows an app to read data from an acceleration sensor, uncalibrated acceleration sensor, or linear acceleration sensor. |
| ohos.permission.GYROSCOPE | normal | system_grant | TRUE | Allows an app to read data from a gyroscope sensor or uncalibrated gyroscope sensor. |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | system_grant | TRUE | Allows a non-system app to obtain information about other apps. |
| ohos.permission.INSTALL_BUNDLE | system_core | system_grant | TRUE | Allows an app to install and uninstall other apps. |
| ohos.permission.MANAGE_SHORTCUTS | system_core | system_grant | TRUE | Allows an app to query and start shortcuts of other apps.|
| ohos.permission.radio.ACCESS_FM_AM | system_core | system_grant | TRUE | Allows an app to access radio services. |
| ohos.permission.SET_TELEPHONY_STATE | system_basic | system_grant | TRUE | Allows an app to change the telephone state. |
| ohos.permission.START_ABILIIES_FROM_BACKGROUND | system_basic | system_grant | TRUE | Allows an app to start Feature abilities in the background. |
| ohos.permission.BUNDLE_ACTIVE_INFO | system_basic | system_grant | TRUE | Allows an app to obtain how long other apps have been running in the foreground or background. |
| ohos.permission.START_INVISIBLE_ABILITY | system_core | system_grant | TRUE | Allows an app to start an invisible ability. |
| ohos.permission.sec.ACCESS_UDID | system_basic | system_grant | TRUE | Allows an app to obtain the Unified Device ID (UDID). |
| ohos.permission.LAUNCH_DATA_PRIVACY_CENTER | system_basic | system_grant | TRUE | Allows an app to switch from its privacy statement page to the <b>Data & privacy</b> page. |
| ohos.permission.MANAGE_MEDIA_RESOURCES | system_basic | system_grant | TRUE | Allows an app to obtain and manage the media resources that are being played on the device.|
| ohos.permission.PUBLISH_AGENT_REMINDER | normal | system_grant | TRUE | Allows an app to use agent-powered reminders. |
| ohos.permission.CONTROL_TASK_SYNC_ANIMATOR | system_core | system_grant | TRUE | Allows apps to use sync task animations. |
| ohos.permission.INPUT_MONITORING | system_core | system_grant | TRUE | Allows the app to listen for input events. Only the system signature apps can apply for this permission. |
| ohos.permission.MANAGE_MISSIONS | system_core | system_grant | TRUE | Allows users to manage ability task stacks. |
| ohos.permission.NOTIFICATION_CONTROLLER | system_core | system_grant | TRUE | Allows an app to manage and subscribe to notifications. Currently, only system apps can apply for this permission. |
| ohos.permission.CONNECTIVITY_INTERNAL | system_basic | system_grant | TRUE | Allows the app to obtain network information or modify network settings. Currently, only system apps can apply for this permission.|
| ohos.permission.ANSWER_CALL | system_basic | user_grant | TRUE | Allows the app to answer incoming calls. |
| ohos.permission.READ_CALENDAR | normal | user_grant | TRUE | Allows an app to read calendar data. |
| ohos.permission.READ_CALL_LOG | system_basic | user_grant | TRUE | Allows an app to read call logs. |
| ohos.permission.READ_CELL_MESSAGES | system_basic | user_grant | TRUE | Allows an app to read cell broadcast messages received by the device. |
| ohos.permission.READ_CONTACTS | system_basic | user_grant | TRUE | Allows an app to read contacts. |
| ohos.permission.READ_MESSAGES | system_basic | user_grant | TRUE | Allows an app to read messages. |
| ohos.permission.RECEIVE_MMS | system_basic | user_grant | TRUE | Allows the app to receive and process MMS messages. |
| ohos.permission.RECEIVE_SMS | system_basic | user_grant | TRUE | Allows the app to receive and process SMS messages. |
| ohos.permission.RECEIVE_WAP_MESSAGES | system_basic | user_grant | TRUE | Allows the app to receive and process WAP messages. |
| ohos.permission.MICROPHONE | normal | user_grant | TRUE | Allows an app to access the microphone. |
| ohos.permission.SEND_MESSAGES | system_basic | user_grant | TRUE | Allows an app to send messages. |
| ohos.permission.WRITE_CALENDAR | normal | user_grant | TRUE | Allows an app to add, remove, and modify calendar events. |
| ohos.permission.WRITE_CALL_LOG | system_basic | user_grant | TRUE | Allows an app to add, remove, and modify call logs. |
| ohos.permission.WRITE_CONTACTS | system_basic | user_grant | TRUE | Allows an app to add, remove, and modify contacts. |
| ohos.permission.DISTRIBUTED_DATASYNC | normal | user_grant | TRUE | Allows an app to exchange data with other devices. |
| ohos.permission.MANAGE_VOICEMAIL | system_basic | user_grant | TRUE | Allows an app to add messages in the voice mailbox. |
| ohos.permission.LOCATION_IN_BACKGROUND | normal | user_grant | FALSE | Allows an app running in the background to obtain the device location. |
| ohos.permission.LOCATION | normal | user_grant | TRUE | Allows an app to obtain the device location. |
| ohos.permission.MEDIA_LOCATION | normal | user_grant | TRUE | Allow an app to access geographical locations in the user's media file. |
| ohos.permission.CAMERA | normal | user_grant | TRUE | Allows an app to use the camera to take photos and record videos. |
| ohos.permission.READ_MEDIA | normal | user_grant | TRUE | Allows an app to read media files from the user's external storage. |
| ohos.permission.WRITE_MEDIA | normal | user_grant | TRUE | Allows an app to read media files from and write media files into the user's external storage. |
| ohos.permission.ACTIVITY_MOTION | normal | user_grant | TRUE | Allows an app to read the current workout status of the user. |
| ohos.permission.READ_HEALTH_DATA | normal | user_grant | TRUE | Allows an app to read the health data of the user. |
Declare the target ACL in the **acl** field of the app's profile in the app installation package, and generate a certificate using the profile signing tool. For details about the signing process, see [Hapsigner Guide](hapsigntool-guidelines.md).
# Permission List
The following lists the permissions defined by the system.
For details about the permission levels, permission authorization modes, and use of the ACL, see [Access Control Overview](accesstoken-overview.md). For details about permission usage examples, see [Access Control Development](accesstoken-guidelines.md).
| Permission | APL | Authorization Mode | Enable ACL| Description |
| -------------------------------------------------------- | ------------ | ------------ | ------- | ------------------------------------------------------------ |
| ohos.permission.USE_BLUETOOTH | normal | system_grant | TRUE | Allows an app to access to Bluetooth configuration. |
| ohos.permission.DISCOVER_BLUETOOTH | normal | system_grant | TRUE | Allows an app to configure Bluetooth on a device, initiate or cancel a scan for Bluetooth devices, and pair with Bluetooth devices. |
| ohos.permission.MANAGE_BLUETOOTH | system_basic | system_grant | TRUE | Allows an app to pair with a Bluetooth device and access the contacts or messages of the device. |
| ohos.permission.INTERNET | normal | system_grant | TRUE | Allows an app to access the Internet. |
| ohos.permission.MODIFY_AUDIO_SETTINGS | normal | system_grant | TRUE | Allows an app to modify audio settings. |
| ohos.permission.ACCESS_NOTIFICATION_POLICY | normal | system_grant | FALSE | Allows an app to access the notification policy on the device. |
| ohos.permission.GET_TELEPHONY_STATE | system_basic | system_grant | TRUE | Allows an app to read telephony information. |
| ohos.permission.REQUIRE_FORM | system_basic | system_grant | TRUE | Allows an app to obtain the Ability Form. |
| ohos.permission.GET_NETWORK_INFO | normal | system_grant | TRUE | Allows an app to obtain network information. |
| ohos.permission.PLACE_CALL | system_basic | system_grant | TRUE | Allows an app to make calls without starting the dialer. |
| ohos.permission.SET_NETWORK_INFO | normal | system_grant | TRUE | Allows an app to set data network information. |
| ohos.permission.REMOVE_CACHE_FILES | system_basic | system_grant | TRUE | Allows the cache of the specified app to be cleared. |
| ohos.permission.REBOOT | system_basic | system_grant | TRUE | Allows an app to restart the device. |
| ohos.permission.RUNNING_LOCK | normal | system_grant | TRUE | Allows an app to obtain a running lock. |
| ohos.permission.ENROLL_BIOMETRIC | system_core | system_grant | FALSE | Allows an app to add or remove biometric data. |
| ohos.permission.ACCESS_BIOMETRIC | normal | system_grant | FALSE | Allows an app to use biometric recognition for identity authentication. |
| ohos.permission.ACCESS_BIOMETRIC_INTERNAL | system_core | system_grant | FALSE | Allows an app to apply for or release biometric recognition resources. |
| ohos.permission.RESET_BIOMETRIC_LOCKOUT | system_core | system_grant | FALSE | Allows an app to reset the maximum number of failures allowed before biometric authentication is locked. |
| ohos.permission.SET_TIME | system_basic | system_grant | TRUE | Allows an app to set the system time. |
| ohos.permission.SET_TIME_ZONE | system_basic | system_grant | TRUE | Allows an app to set the system time zone. |
| ohos.permission.DOWNLOAD_SESSION_MANAGER | system_core | system_grant | TRUE | Allows an app to manage the download sessions. |
| ohos.permission.COMMONEVENT_STICKY | normal | system_grant | TRUE | Allows an app to publish sticky common events. |
| ohos.permission.SYSTEM_FLOAT_WINDOW | normal | system_grant | TRUE | Allows an app to be displayed in a floating window on top of other apps. |
| ohos.permission.POWER_MANAGER | system_core | system_grant | TRUE | Allows an app to hibernate or wake up the device by calling APIs. |
| ohos.permission.REFRESH_USER_ACTION | system_basic | system_grant | TRUE | Allows an app to reset the screen timeout counter when a user input event occurs, such as pressing a key or touching the screen. |
| ohos.permission.POWER_OPTIMIZATION | system_basic | system_grant | TRUE | Allows an app to set power saving mode, obtain configuration of the power saving mode, and receive notifications of the configuration changes.|
| ohos.permission.REBOOT_RECOVERY | system_basic | system_grant | TRUE | Allows an app to restart the device and enter Recovery mode. |
| ohos.permission.MANAGE_LOCAL_ACCOUNTS | system_basic | system_grant | TRUE | Allows an app to manage local user accounts. |
| ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | system_basic | system_grant | TRUE | Allows access between multiple OS accounts. |
| ohos.permission.VIBRATE | normal | system_grant | TRUE | Allows an app to control vibration. |
| ohos.permission.CONNECT_IME_ABILITY | system_core | system_grant | TRUE | Allows an app or service to bind to the **InputMethodAbility**. |
| ohos.permission.CONNECT_SCREEN_SAVER_ABILITY | system_core | system_grant | TRUE | Allows an app or service to bind to the **ScreenSaverAbility**. |
| ohos.permission.READ_SCREEN_SAVER | system_basic | system_grant | TRUE | Allows an app to read the screen saver information, such as the list of screen savers that have been installed and the activated one. |
| ohos.permission.WRITE_SCREEN_SAVER | system_basic | system_grant | TRUE | Allows an app to modify the screen saver information, such as activating and previewing a screen saver. |
| ohos.permission.SET_WALLPAPER | normal | system_grant | TRUE | Allows an app to set a static wallpaper. |
| ohos.permission.GET_WALLPAPER | system_basic | system_grant | TRUE | Allows an app to read wallpaper files. |
| ohos.permission.CHANGE_ABILITY_ENABLED_STATE | system_basic | system_grant | TRUE | Allows an app to enable or disable an app or component. |
| ohos.permission.ACCESS_MISSIONS | system_basic | system_grant | TRUE | Allows an app to obtain information about running processes and mission in a mission stack. |
| ohos.permission.CLEAN_BACKGROUND_PROCESSES | normal | system_grant | TRUE | Allows an app to clear background processes based on their bundle names. |
| ohos.permission.KEEP_BACKGROUND_RUNNING | normal | system_grant | TRUE | Allows a Service ability to keep running in the background. |
| ohos.permission.UPDATE_CONFIGURATION | system_basic | system_grant | TRUE | Allows an app to modify system settings. |
| ohos.permission.UPDATE_SYSTEM | system_basic | system_grant | TRUE | Allows an app to call the update API. |
| ohos.permission.FACTORY_RESET | system_basic | system_grant | TRUE | Allows an app to call the API for restoring factory settings. |
| ohos.permission.GRANT_SENSITIVE_PERMISSIONS | system_core | system_grant | TRUE | Allows an app to grant sensitive permissions to other apps. |
| ohos.permission.REVOKE_SENSITIVE_PERMISSIONS | system_core | system_grant | TRUE | Allows an app to revoke sensitive permissions granted to other apps. |
| ohos.permission.GET_SENSITIVE_PERMISSIONS | system_core | system_grant | TRUE | Allows an app to obtain the sensitive permissions that have been granted to other apps. |
| ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION | system_core | system_grant | TRUE | Allows an app to set the attributes of apps of other users. |
| ohos.permission.LISTEN_BUNDLE_CHANGE | system_basic | system_grant | TRUE | Allows an app to listen for changes in other apps, when they are installed, updated, or uninstalled. |
| ohos.permission.GET_BUNDLE_INFO | normal | system_grant | TRUE | Allows a non-system app to obtain information about other apps. |
| ohos.permission.ACCELEROMETER | normal | system_grant | TRUE | Allows an app to read data from an acceleration sensor, uncalibrated acceleration sensor, or linear acceleration sensor. |
| ohos.permission.GYROSCOPE | normal | system_grant | TRUE | Allows an app to read data from a gyroscope sensor or uncalibrated gyroscope sensor. |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | system_grant | TRUE | Allows a non-system app to obtain information about other apps. |
| ohos.permission.INSTALL_BUNDLE | system_core | system_grant | TRUE | Allows an app to install and uninstall other apps. |
| ohos.permission.MANAGE_SHORTCUTS | system_core | system_grant | TRUE | Allows an app to query and start shortcuts of other apps.|
| ohos.permission.radio.ACCESS_FM_AM | system_core | system_grant | TRUE | Allows an app to access radio services. |
| ohos.permission.SET_TELEPHONY_STATE | system_basic | system_grant | TRUE | Allows an app to change the telephone state. |
| ohos.permission.START_ABILIIES_FROM_BACKGROUND | system_basic | system_grant | TRUE | Allows an app to start Feature abilities in the background. |
| ohos.permission.BUNDLE_ACTIVE_INFO | system_basic | system_grant | TRUE | Allows an app to obtain how long other apps have been running in the foreground or background. |
| ohos.permission.START_INVISIBLE_ABILITY | system_core | system_grant | TRUE | Allows an app to start an invisible ability. |
| ohos.permission.sec.ACCESS_UDID | system_basic | system_grant | TRUE | Allows an app to obtain the Unified Device ID (UDID). |
| ohos.permission.LAUNCH_DATA_PRIVACY_CENTER | system_basic | system_grant | TRUE | Allows an app to switch from its privacy statement page to the <b>Data & privacy</b> page. |
| ohos.permission.MANAGE_MEDIA_RESOURCES | system_basic | system_grant | TRUE | Allows an app to obtain and manage the media resources that are being played on the device.|
| ohos.permission.PUBLISH_AGENT_REMINDER | normal | system_grant | TRUE | Allows an app to use agent-powered reminders. |
| ohos.permission.CONTROL_TASK_SYNC_ANIMATOR | system_core | system_grant | TRUE | Allows apps to use sync task animations. |
| ohos.permission.INPUT_MONITORING | system_core | system_grant | TRUE | Allows an app to listen for input events. Only the system signature apps can apply for this permission. |
| ohos.permission.MANAGE_MISSIONS | system_core | system_grant | TRUE | Allows an app to manage ability mission stacks. |
| ohos.permission.NOTIFICATION_CONTROLLER | system_core | system_grant | TRUE | Allows an app to manage and subscribe to notifications. |
| ohos.permission.CONNECTIVITY_INTERNAL | system_basic | system_grant | TRUE | Allows an app to obtain network information or modify network settings. |
| ohos.permission.SET_ABILITY_CONTROLLER | system_basic | system_grant | TRUE | Allows an app to set the start and stop of the ability. |
| ohos.permission.USE_USER_IDM | system_basic | system_grant | FALSE | Allows an app to access the system identity credential information. |
| ohos.permission.MANAGE_USER_IDM | system_basic | system_grant | FALSE | Allows an app to use the system identity credential management capability to enroll, modify, and delete PINs, face images, and fingerprints.|
| ohos.permission.ACCESS_BIOMETRIC | normal | system_grant | TRUE | Allows an app to use biometric recognition for identity authentication. |
| ohos.permission.ACCESS_USER_AUTH_INTERNAL | system_basic | system_grant | FALSE | Allows an app to use the system identity authentication capability to authenticate or identify users. |
| ohos.permission.ACCESS_PIN_AUTH | system_basic | system_grant | FALSE | Allows a system application to call the PIN input interface to present the password input dialog box for users.|
| ohos.permission.GET_RUNNING_INFO | system_basic | system_grant | TRUE | Allows an app to obtain running status information. |
| ohos.permission.CLEAN_APPLICATION_DATA | system_basic | system_grant | TRUE | Allow an app to clear app data. |
| ohos.permission.RUNNING_STATE_OBSERVER | system_basic | system_grant | TRUE | Allows an app to observe the app status. |
| ohos.permission.CAPTURE_SCREEN | system_core | system_grant | TRUE | Allows an app to take screenshots. |
| ohos.permission.GET_WIFI_INFO | normal | system_grant | TRUE | Allow an app to obtain WLAN information. |
| ohos.permission.GET_WIFI_INFO_INTERNAL | system_core | system_grant | TRUE | Allows an app to obtain WLAN information. |
| ohos.permission.SET_WIFI_INFO | normal | system_grant | TRUE | Allows an app to set WLAN devices. |
| ohos.permission.GET_WIFI_PEERS_MAC | system_core | system_grant | TRUE | Allows an app to obtain the MAC address of the peer WLAN or Bluetooth device. |
| ohos.permission.GET_WIFI_LOCAL_MAC | system_basic | system_grant | TRUE | Allows an app to obtain the MAC address of the local WLAN or Bluetooth device. |
| ohos.permission.GET_WIFI_CONFIG | system_basic | system_grant | TRUE | Allows an app to obtain the WLAN configuration. |
| ohos.permission.SET_WIFI_CONFIG | system_basic | system_grant | TRUE | Allows an app to set WLAN information. |
| ohos.permission.MANAGE_WIFI_CONNECTION | system_core | system_grant | TRUE | Allow an app to manage WLAN connections. |
| ohos.permission.MANAGE_WIFI_HOTSPOT | system_core | system_grant | TRUE | Allow an app to enable or disable Wi-Fi hotspots. |
| ohos.permission.GET_ALL_APP_ACCOUNTS | system_core | system_grant | FALSE | Allows an app to obtain all app account information. |
| ohos.permission.MANAGE_SECURE_SETTINGS | system_basic | system_grant | TRUE | Allows an app to modify security settings. |
| ohos.permission.READ_DFX_SYSEVENT | system_basic | system_grant | FALSE | Allows an app to obtain all app account information. |
| ohos.permission.MANAGE_ADMIN | system_core | system_grant | TRUE | Allows an app to activate the device administrator app. |
| ohos.permission.EDM_MANAGE_DATETIME | normal | system_grant | FALSE | Allows the device administrator app to set the system time. |
| ohos.permission.NFC_TAG | normal | system_grant | FALSE | Allows an app to read NFC tag information. |
| ohos.permission.NFC_CARD_EMULATION | normal | system_grant | FALSE | Allows an app to implement card emulation. |
| ohos.permission.PERMISSION_USED_STATS | system_core | system_grant | TRUE | Allows a system application to access the permission usage records. |
| ohos.permission.NOTIFICATION_AGENT_CONTROLLER | system_core | system_grant | TRUE | Allows an app to send agent notifications. |
| ohos.permission.ANSWER_CALL | system_basic | user_grant | TRUE | Allows an app to answer incoming calls. |
| ohos.permission.READ_CALENDAR | normal | user_grant | TRUE | Allows an app to read calendar data. |
| ohos.permission.READ_CALL_LOG | system_basic | user_grant | TRUE | Allows an app to read call logs. |
| ohos.permission.READ_CELL_MESSAGES | system_basic | user_grant | TRUE | Allows an app to read cell broadcast messages received by the device. |
| ohos.permission.READ_CONTACTS | system_basic | user_grant | TRUE | Allows an app to read contacts. |
| ohos.permission.READ_MESSAGES | system_basic | user_grant | TRUE | Allows an app to read messages. |
| ohos.permission.RECEIVE_MMS | system_basic | user_grant | TRUE | Allows an app to receive and process MMS messages. |
| ohos.permission.RECEIVE_SMS | system_basic | user_grant | TRUE | Allows an app to receive and process SMS messages. |
| ohos.permission.RECEIVE_WAP_MESSAGES | system_basic | user_grant | TRUE | Allows an app to receive and process WAP messages. |
| ohos.permission.MICROPHONE | normal | user_grant | TRUE | Allows an app to access the microphone. |
| ohos.permission.SEND_MESSAGES | system_basic | user_grant | TRUE | Allows an app to send messages. |
| ohos.permission.WRITE_CALENDAR | normal | user_grant | TRUE | Allows an app to add, remove, and modify calendar events. |
| ohos.permission.WRITE_CALL_LOG | system_basic | user_grant | TRUE | Allows an app to add, remove, and modify call logs. |
| ohos.permission.WRITE_CONTACTS | system_basic | user_grant | TRUE | Allows an app to add, remove, and modify contacts. |
| ohos.permission.DISTRIBUTED_DATASYNC | normal | user_grant | TRUE | Allows an app to exchange data with other devices. |
| ohos.permission.MANAGE_VOICEMAIL | system_basic | user_grant | TRUE | Allows an app to leave messages in the voice mailbox. |
| ohos.permission.LOCATION_IN_BACKGROUND | normal | user_grant | FALSE | Allows an app running in the background to obtain the device location. |
| ohos.permission.LOCATION | normal | user_grant | TRUE | Allows an app to obtain the device location. |
| ohos.permission.MEDIA_LOCATION | normal | user_grant | TRUE | Allow an app to access geographical locations in the user's media file. |
| ohos.permission.CAMERA | normal | user_grant | TRUE | Allows an app to use the camera to take photos and record videos. |
| ohos.permission.READ_MEDIA | normal | user_grant | TRUE | Allows an app to read media files from the user's external storage. |
| ohos.permission.WRITE_MEDIA | normal | user_grant | TRUE | Allows an app to read media files from and write media files into the user's external storage. |
| ohos.permission.ACTIVITY_MOTION | normal | user_grant | TRUE | Allows an app to read the current workout status of the user. |
| ohos.permission.READ_HEALTH_DATA | normal | user_grant | TRUE | Allows an app to read the health data of the user. |
| ohos.permission.GET_DEFAULT_APPLICATION | system_core | system_grant | TRUE | Allows an app to query default apps. |
| ohos.permission.SET_DEFAULT_APPLICATION | system_core | system_grant | TRUE | Allows an app to set and reset default apps. |
| ohos.permission.MANAGE_DISPOSED_APP_STATUS | system_core | system_grant | TRUE | Allows an app to set and query the app handling state. |
# Redirecting to the Dial Screen
You can use this service for your application to redirect users to the dial screen and display the dialed number. When the **makeCall** API is called, the phone or tablet will automatically display the dial screen. On this screen, the user can choose to make an audio or video call and specify the SIM card.
You can use this service for your application to redirect users to the dial screen and display the dialed number. When the **makeCall** API is called, the device will automatically display the dial screen. On this screen, the user can choose to make an audio or video call and specify the SIM card.
## Available APIs
......
......@@ -11,7 +11,7 @@ The "js" tag contains the instance name, window style, and page route informatio
| window | Object | - | No | Window information. For details, see ["window"](#window). |
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The "name", "window", and "pages" tags are configured in the "js" tag of the config.json file.
......@@ -32,7 +32,7 @@ The "pages" defines the route information of each page. Each page consists of th
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
>
> - The first page in the pages list is the home page, also referred to as the entry, of the application.
>
......@@ -47,14 +47,15 @@ The "window" defines window-related configurations. To solve the screen adaptati
- Set autoDesignWidth to true, the designWidth field will be ignored, and the component and layout will be scaled automatically based on the screen density. The logical screen width is automatically calculated based on the physical screen width and screen density. The logical screen width may vary depending on the device. Use the relative layout to adapt to different devices. For example, on a device with a resolution of 466x466 and 320 DPI (a screen density of 2x, with 160 DPI as the base), 1 px is equivalent to 2 physical px.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> 1. The default &lt;length&gt; value in the current style is calculated based on the screen density. For example, if the screen density is x2 (with 160 DPI as the baseline) and the default &lt;length&gt; value is 1 px, the actual length rendered on the device is 2 physical px.
>
> 2. Values of autoDesignWidth and designWidth do not affect how the default &lt;length&gt; value is calculated and the final effect.
| Attribute | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- |
| | | | | |
| designWidth | number | No | 720<br/> | Logical screen width, which is a reference value for page design. The actual display width is scaled at the ratio of the value to the device width. |
| designWidth | number | No | 720 | Logical screen width, which is a reference value for page design. The actual display width is scaled at the ratio of the value to the device width. |
| autoDesignWidth | boolean | No | false | Whether to automatically calculate the baseline width. If autoDesignWidth is set to true, designWidth is ignored. The baseline width is calculated based on the physical screen width and screen density. |
The following is a sample code snippet:
......
......@@ -109,7 +109,7 @@ Table 3 $t function parameters
| Parameter | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| path | string | Yes | Path of the language resource key |
| params | Array\|Object | No | Content used to replace placeholders during runtime. There are two types of placeholders available:<br/>- Named placeholder, for example, {name}. The actual content must be of the object type, for example, \```$t('strings.object', {name:'Hello world'})```.<br/>- Digit placeholder, for example, {0}. The actual content must be of the array type, for example, \```$t('strings.array', [Hello world']```. |
| params | Array\|Object | No | Content used to replace placeholders during runtime. There are two types of placeholders available:<br/>- Named placeholder, for example, {name}. The actual content must be of the object type, for example, ```$t('strings.object', {name:'Hello world'})```.<br>- Digit placeholder, for example, {0}. The actual content must be of the array type, for example, ```$t('strings.array', [Hello world']```. |
- Example code for simple formatting
......@@ -157,6 +157,7 @@ Table 3 $t function parameters
```
- Singular-plural formatting
Table 4 Singular-plural formatting
| Attribute | Type | Parameter | Mandatory | Description |
......
......@@ -159,8 +159,8 @@ The following is an example for you to use the :active pseudo-class to control t
}
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> Pseudo-classes are not supported for the <popup> component and its child components, including, <dialog>, <menu>, <option>, and <picker>.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> Pseudo-classes are not supported for the <popup> component and its child components, including <popup>, <dialog>, <menu>, <option>, and <picker>.
## Precompiled Styles
......@@ -199,7 +199,7 @@ Precompilation is a program that uses specific syntax to generate CSS files. It
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> Place precompiled style files in the common directory.
## CSS Style Inheritance<sup>6+</sup>
......
......@@ -41,7 +41,7 @@ export default {
}
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> - To make the array data modification take effect, use the splice method to change array items.
>
> - ECMAScript 6 (ES6) syntax is not supported in HML.
......@@ -135,7 +135,7 @@ Bubbling event binding covers the following:
- Bind an event callback for event bubbling: on:{event}.bubble. on:{event} is equivalent to on:{event}.bubble.
- Bind an event callback, but stop the event from bubbling upwards: grab:{event}.bubble. grab:{event} is equivalent to grab:{event}.bubble.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> For details about bubbling events, see [Universal Events](../reference/arkui-js/js-components-common-events.md)
- Example
......@@ -171,7 +171,7 @@ Bubbling event binding covers the following:
}
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> Events bound using a traditional statement (such as onclick) will bubble only when the API version in use is 6 or later.
## Capturing Event Binding<sup>5+</sup>
......@@ -260,7 +260,7 @@ The for loop supports the following statements:
- for="(i, v) in array": i indicates the element index, and v indicates the element variable. All elements of the array object will be looped through.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> - Each element in the array must have the data attribute specified by tid. Otherwise, an exception may occur.
>
> - The attribute specified by tid in the array must be unique. Otherwise, performance loss occurs. In the above example, only id and name can be used as tid because they are unique fields.
......@@ -353,7 +353,7 @@ export default {
}
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> Do not use for and if attributes at the same time in an element.
## Logic Control Block
......
......@@ -23,10 +23,11 @@ Basic page elements include title, text, and image areas. Each basic element may
- Container components and their types
You can disassemble elements on the page first and then implement them in sequence. This reduces visual confusion and logical conflicts caused by element nesting and improves code readability for easier modification. For example, as shown below, you disassemble the page elements and elements in the comment area.
figure1 Page layout
Figure 1 Page layout
![en-us_image_0000001222967792](figures/en-us_image_0000001222967792.png)
figure2 Layout of the comment area
Figure 2 Layout of the comment area
![en-us_image_0000001267767889](figures/en-us_image_0000001267767889.png)
# Window Overview
# Window Manager Overview
The Window Manager subsystem provides basic capabilities of window management. It is the basis for UI display.
The Window Manager subsystem enables multiple applications to simultaneously display on the same screen and interact with users. For each application, you need to design the interaction interface in the fixed window area. A window acts as a display container of the application UI, and the Window Manager subsystem organizes the interaction UIs into a form visible to end users.
......
......@@ -261,7 +261,7 @@ int32_t CodecDaiHwParams(const struct AudioCard *card, const struct AudioPcmHwPa
unsigned int bitWidth;
struct CodecDaiParamsVal codecDaiParamsVal;
...
int ret = AudioFramatToBitWidth(param->format, &bitWidth);
int ret = AudioFormatToBitWidth(param->format, &bitWidth);
...
codecDaiParamsVal.frequencyVal = param->rate;
codecDaiParamsVal.formatVal = bitWidth;
......@@ -1019,7 +1019,7 @@ int32_t DaiHwParams(const struct AudioCard *card, const struct AudioPcmHwParams
struct DaiData *data = DaiDataFromCard(card);
data->pcmInfo.channels = param->channels;
...
AudioFramatToBitWidth(param->format, &bitWidth);
AudioFormatToBitWidth(param->format, &bitWidth);
...
data->pcmInfo.bitWidth = bitWidth;
data->pcmInfo.rate = param->rate;
......
......@@ -69,7 +69,7 @@ The sensor driver model provides APIs for the hardware service to make sensor se
| int32_t GetAllSensors(struct SensorInformation **sensorInfo, int32_t *count) | Obtains information about all registered sensors in the system. The sensor information includes the sensor name, sensor vendor, firmware version, hardware version, sensor type ID, sensor ID, maximum range, accuracy, and power consumption.|
| int32_t Enable(int32_t sensorId) | Enables a sensor. The subscriber can obtain sensor data only after the sensor is enabled.|
| int32_t Disable(int32_t sensorId) | Disables a sensor.|
| int32_t SetBatch(iint32_t sensorId, int64_t samplingInterval, int64_t reportInterval) | Sets the sampling interval and data reporting interval for a sensor.|
| int32_t SetBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval) | Sets the sampling interval and data reporting interval for a sensor.|
| int32_t SetMode(int32_t sensorId, int32_t mode) | Sets the data reporting mode for a sensor.|
| int32_t SetOption(int32_t sensorId, uint32_t option) | Sets options for a sensor, including its range and accuracy.|
| int32_t Register(int32_t groupId, RecordDataCallback cb) | Registers a sensor data callback based on the group ID.|
......@@ -575,7 +575,7 @@ HWTEST_F(HdfSensorTest,TestAccelDriver_001, TestSize.Level0)
}
/* Print the obtained sensor list. */
for (int i = 0; i < count; i++) {
printf("get sensoriId[%d], info name[%s]\n\r", sensorInfo[i]->sensorId, sensorInfo[i]->sensorName);
printf("get sensorId[%d], info name[%s]\n\r", sensorInfo[i]->sensorId, sensorInfo[i]->sensorName);
}
ret = g_sensorDev->Enable(accelSensorId);
EXPECT_EQ(0, ret);
......
......@@ -260,7 +260,7 @@ The method for determining the GPIO pin number varies depending on the GPIO cont
```
## Development Example
## Example
The procedure is as follows:
......
......@@ -28,7 +28,7 @@ struct GpioMethod {
int32_t (*unsetIrq)(struct GpioCntlr *cntlr, uint16_t local);
int32_t (*enableIrq)(struct GpioCntlr *cntlr, uint16_t local);
int32_t (*disableIrq)(struct GpioCntlr *cntlr, uint16_t local);
}
};
```
**Table 1** Description of the callback functions in GpioMethod
......@@ -63,7 +63,7 @@ The GPIO module adaptation involves the following steps:
- Initialize **GpioCntlr**.
- Instantiate **GpioMethod** in the **GpioCntlr** object.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> For details about the callbacks in **GpioMethod**, see [Available APIs](#available_apis).
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> For details about the functions in **GpioMethod**, see [Available APIs](#available-apis).
4. Debug the driver.
......@@ -72,7 +72,7 @@ The GPIO module adaptation involves the following steps:
## Development Example
The following uses **gpio_hi35xx.c** as an example to present the information to be provided by the vendor for implementing device functions.
The following uses **gpio_hi35xx.c** as an example to present the information required for implementing device functions.
1. Instantiate the driver entry.
......@@ -143,7 +143,7 @@ The following uses **gpio_hi35xx.c** as an example to present the information to
3. Initialize the **GpioCntlr** object at the core layer, including defining a custom structure (to pass parameters and data) and implementing the **HdfDriverEntry** member functions (**Init** and **Release**) to instantiate **GpioMethod** in **GpioCntlr** (so that the underlying driver functions can be called).
- Defining a custom structure
To the driver, the custom structure holds parameters and data. The **DeviceResourceIface** method provided by the HDF reads the values in the **gpio_config.hcs** file to initialize the members in the custom structure and passes important parameters, such as the GPIO group number and the number of pins, to the **GpioCntlr** object at the core layer.
To the driver, the custom structure holds parameters and data. The **DeviceResourceIface** method provided by the HDF reads the values in the **gpio_config.hcs** file to initialize the members in the custom structure and pass important parameters, such as the GPIO group number and the number of pins, to the **GpioCntlr** object at the core layer.
```
......
......@@ -467,7 +467,7 @@ The following is an example of closing an HDMI controller:
HdmiClose(hdmiHandle);
```
### Development Example
### Example
This following example shows how to use HDMI APIs to manage an HDMI device on a Hi3516D V300 development board.
......
......@@ -235,7 +235,7 @@ The HDMI module adaptation involves the following steps:
> ![](../public_sys-resources/icon-note.gif) **NOTE**
>
>
> To the driver, the custom structure holds parameters and data. The **DeviceResourceIface** method provided by the HDF reads the values in the **hdmi_config.hcs** file to initialize the members in the custom structure and passes important parameters, such as the device number and bus number, to the **HdmiCntlr** object at the core layer.
> To the driver, the custom structure holds parameters and data. The **DeviceResourceIface** method provided by the HDF reads the values in the **hdmi_config.hcs** file to initialize the members in the custom structure and pass important parameters, such as the device number and bus number, to the **HdmiCntlr** object at the core layer.
```c
struct HdmiAdapterHost {
......
# MIPI CSI<a name="title_MIPI_CSIDes"></a>
# MIPI CSI
## Overview<a name="section1_MIPI_CSIDes"></a>
## Overview
Defined by the Mobile Industry Processor Interface (MIPI) Alliance, the Camera Serial Interface (CSI) is a specification that allows data to be transmitted from the camera to the host processor on mobile platforms. As the second release, the MIPI CSI-2 consists of the application layer, protocol layer, and physical layer. It supports a maximum of four-lane data transmission and a single-lane transmission rate of 1 Gbit/s.
The physical layer supports the high speed (HS) and low power (LP) modes. Using low-voltage differential signaling (LVDS), the HS mode delivers 80 Mbit/s to 1 Gbit/s transmission speed but high power consumption. The unidirectional LP mode provides lower power consumption but lower transmission speed (< 10 Mbit/s). The blend of the two modes ensures high-speed transmission of massive data (such as images) and minimized power consumption when less data is transmitted.
The physical layer supports the high speed (HS) and low speed (LS) modes. Using low-voltage differential signaling (LVDS), the HS mode delivers 80 Mbit/s to 1 Gbit/s transmission speed but high power consumption. The unidirectional LS mode provides lower power consumption but lower transmission speed (< 10 Mbit/s). The blend of the two modes ensures high-speed transmission of massive data (such as images) and minimized power consumption when less data is transmitted.
The figure below shows a simplified CSI. The D-PHY transmits data by using one pair of source-synchronized differential clocks and one to four pairs of differential data lanes. Data is transmitted in Double Data Rate (DDR) mode, that is, data is transmitted on both the rising and falling edges of the clock.
**Figure 1** CSI TX and RX interfaces<a name="fig1_MIPI_CSIDes"></a>
![](figures/CSI_TX-RX_interface.png)
**Figure 1** CSI TX and RX interfaces
![](figures/CSI_TX-RX_interface.png)
### ComboDevAttr Structure<a name="section1.1_MIPI_CSIDes"></a>
### ComboDevAttr Structure
**Table 1** ComboDevAttr structure
......@@ -26,7 +27,7 @@ The figure below shows a simplified CSI. The D-PHY transmits data by using one p
| MIPIAttr | Attributes of the MIPI device. |
| lvdsAttr | Attributes of the LVDS, sub-LVDS, or HiSPi device. |
### ExtDataType Structure<a name="section1.2_MIPI_CSIDes"></a>
### ExtDataType Structure
**Table 2** ExtDataType structure
......@@ -39,33 +40,34 @@ The figure below shows a simplified CSI. The D-PHY transmits data by using one p
| extDataBitWidth | Bit depth of an image. |
| extDataType | Pointer to the YUV, raw data format, and bit depth.|
### Available APIs<a name="section1.3_MIPI_CSIDes"></a>
### Available APIs
**Table 3** MIPI CSI APIs
<a name="table3_MIPI_CSIDes"></a>
| Category| API|
| Category| API|
| -------- | -------- |
| Opening or closing the MIPI CSI controller operation handle| **MipiCsiOpen**: opens the MIPI CSI controller operation handle.<br>**MipiCsiClose**: closes the MIPI CSI controller operation handle.|
| Setting MIPI CSI parameters| **MipiCsiSetComboDevAttr**: sets parameters of the MIPI, CMOS, or LVDS camera to the controller. The parameters include the working mode, image area, image depth, data rate, and physical channel.<br>**MipiCsiSetExtDataType** (optional): sets the YUV and RAW data formats and bit depths.<br>**MipiCsiSetHsMode**: sets the MIPI RX lane distribution. Set the mode based on the hardware connection.<br>**MipiCsiSetPhyCmvmode**: sets the common-mode voltage (CMV) mode.|
| Setting MIPI CSI attributes | **MipiCsiSetComboDevAttr**: sets attributes of the MIPI, CMOS, or LVDS camera to the controller. The attributes include the working mode, image area, image depth, data rate, and physical channel.<br>**MipiCsiSetExtDataType** (optional): sets the YUV and RAW data formats and bit depths.<br>**MipiCsiSetHsMode**: sets the MIPI RX lane distribution. Set the mode based on the hardware connection.<br>**MipiCsiSetPhyCmvmode**: sets the common-mode voltage (CMV) mode. |
| Resetting a sensor or deasserting the reset of a sensor| **MipiCsiResetSensor**: resets a sensor.<br>**MipiCsiUnresetSensor**: deasserts the reset of a sensor.|
| Resetting the MIPI RX or deasserting the reset of the MIPI RX| **MipiCsiResetRx**: resets the MIPI&amp;nbsp;RX. The value of **enSnsType** varies depending on the value of **s32WorkingViNum**.<br>**MipiCsiUnresetRx**: deasserts the reset on the MIPI&amp;nbsp;RX.|
| Enabling or disabling the MIPI clock| **MipiCsiEnableClock**: enables the MIPI clock. The **enSnsType** passed by the upper-layer function during electrophoresis determines whether MIPI or LVDS is used.<br>**MipiCsiDisableClock**: disables the MIPI clock.|
| Enabling or disabling the MIPI sensor clock| **MipiCsiEnableSensorClock**: enables the MIPI sensor clock.<br>**MipiCsiDisableSensorClock**: disables the MIPI sensor clock.|
## Usage Guidelines<a name="section2_MIPI_CSIDes"></a>
## Usage Guidelines
### How to Use<a name="section2.1_MIPI_CSIDes"></a>
### How to Use
The figure below illustrates how to use the APIs.
The figure below illustrates the general development process.
**Figure 2** Using MIPI CSI driver APIs
![](figures/using-MIPI-CSI-process.png)
### Opening the MIPI CSI Controller Operation Handle<a name="section2.2_MIPI_CSIDes"></a>
### Opening a MIPI CSI Controller Operation Handle
Before starting MIPI CSI communication, call **MipiCsiOpen** to open the MIPI CSI device handle. This function returns the MIPI CSI device handle with the specified lane ID.
......@@ -81,10 +83,10 @@ DevHandle MipiCsiOpen(uint8_t id);
| ---------- | ----------------------------------------------- |
| id | MIPI CSI lane ID. |
| **Return Value**| **Description** |
| NULL | The operation fails. |
| Device handle | MIPI CSI device handle with the specified lane ID. The data type is **DevHandle**.|
| NULL | The operation failed. |
| Device handle | The operation is successful. The MIPI CSI device handle with the specified lane ID is returned. The data type is **DevHandle**. |
For example, open the controller operation handle for MIPI CSI lane 0:
For example, open the controller operation handle of MIPI CSI lane 0:
```c
DevHandle mipiCsiHandle = NULL; /* Device handle */
......@@ -98,9 +100,9 @@ if (MipiCsiHandle == NULL) {
}
```
### Setting MIPI CSI Parameters<a name="section2.3_MIPI_CSIDes"></a>
### Setting MIPI CSI Attributes
- Set MIPI CSI parameters.
- Set MIPI CSI attributes.
```c
int32_t MipiCsiSetComboDevAttr(DevHandle handle, ComboDevAttr *pAttr);
......@@ -116,7 +118,7 @@ if (MipiCsiHandle == NULL) {
| pAttr | Pointer to the MIPI CSI structure.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```c
int32_t ret;
......@@ -155,7 +157,7 @@ if (MipiCsiHandle == NULL) {
| dataType | Pointer to the YUV, raw data format, and bit depth.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```c
int32_t ret;
......@@ -195,7 +197,7 @@ if (MipiCsiHandle == NULL) {
| laneDivideMode | Lane mode. |
| **Return Value** | **Description**|
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```c
int32_t ret;
......@@ -228,7 +230,7 @@ if (MipiCsiHandle == NULL) {
| devno | Device number. |
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```c
int32_t ret;
......@@ -247,7 +249,7 @@ if (MipiCsiHandle == NULL) {
}
```
### Resetting a Sensor or Deasserting the Reset of a Sensor<a name="section2.4_MIPI_CSIDes"></a>
### Resetting a Sensor or Deasserting the Reset of a Sensor
- Reset a sensor.
......@@ -262,10 +264,10 @@ if (MipiCsiHandle == NULL) {
| Parameter | Description |
| -------------- | ------------------------------------------------ |
| handle | Controller operation handle. |
| snsResetSource | Sensor's reset signal cable number, which is called reset source of the sensor in software.|
| snsResetSource | Sensor's reset signal cable number, which is called "sensor reset source" in software. |
| **Return Value** | **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```c
int32_t ret;
......@@ -294,10 +296,10 @@ if (MipiCsiHandle == NULL) {
| Parameter | Description |
| -------------- | ------------------------------------------------ |
| handle | Controller operation handle. |
| snsResetSource | Sensor's reset signal cable number, which is called reset source of the sensor in software.|
| snsResetSource | Sensor's reset signal cable number, which is called "sensor reset source" in software. |
| **Return Value** | **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```c
int32_t ret;
......@@ -313,7 +315,7 @@ if (MipiCsiHandle == NULL) {
}
```
### Resetting the MIPI RX or Deasserting the Reset of the MIPI RX<a name="section2.5_MIPI_CSIDes"></a>
### Resetting the MIPI RX or Deasserting the Reset of the MIPI RX
- Reset the MIPI RX.
......@@ -331,7 +333,7 @@ if (MipiCsiHandle == NULL) {
| comboDev | MIPI RX or LVDS channel number.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```c
int32_t ret;
......@@ -363,7 +365,7 @@ if (MipiCsiHandle == NULL) {
| comboDev | MIPI RX or LVDS channel number.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```c
int32_t ret;
......@@ -379,7 +381,7 @@ if (MipiCsiHandle == NULL) {
}
```
### Enabling or Disabling the MIPI Clock<a name="section2.6_MIPI_CSIDes"></a>
### Enabling or Disabling the MIPI Clock
- Enable the MIPI clock.
......@@ -397,7 +399,7 @@ if (MipiCsiHandle == NULL) {
| comboDev | Channel number. |
| **Return Value**| **Description**|
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```c
int32_t ret;
......@@ -429,7 +431,7 @@ if (MipiCsiHandle == NULL) {
| comboDev | Channel number. |
| **Return Value**| **Description**|
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```c
int32_t ret;
......@@ -445,7 +447,7 @@ if (MipiCsiHandle == NULL) {
}
```
### Enabling or Disabling the MIPI Sensor Clock<a name="section2.7_MIPI_CSIDes"></a>
### Enabling or Disabling the MIPI Sensor Clock
- Enable the MIPI sensor clock.
......@@ -463,7 +465,7 @@ if (MipiCsiHandle == NULL) {
| snsClkSource | Sensor's clock signal cable number, which is called clock source of the sensor in software.|
| **Return Value** | **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```c
int32_t ret;
......@@ -495,7 +497,7 @@ if (MipiCsiHandle == NULL) {
| snsClkSource | Sensor's clock signal cable number, which is called clock source of the sensor in software.|
| **Return Value** | **Description** |
| 0 | The operation is successful. |
| Negative value | The operation fails. |
| Negative value | The operation failed. |
```c
int32_t ret;
......@@ -511,9 +513,9 @@ if (MipiCsiHandle == NULL) {
}
```
### Closing a MIPI CSI Controller Operation Handle<a name="section2.8_MIPI_CSIDes"></a>
### Closing a MIPI CSI Controller Operation Handle
After the MIPI CSI communication, close the MIPI CSI controller handle by calling the following function:
Call **MipiCsiClose()** to close the MIPI CSI controller handle after the MIPI CSI communication is complete.
```c
void MipiCsiClose(DevHandle handle);
......@@ -533,7 +535,7 @@ This function releases the resources requested by **MipiCsiOpen**.
MipiCsiClose(MIPIHandle); /* Close the operation handle of the MIPI CSI controller. */
```
## Development Example<a name="section3_MIPI_CSIDes"></a>
## Example
The sample code is as follows:
......
# MIPI CSI<a name="EN-US_TOPIC_0000001198067744"></a>
# MIPI CSI
## Overview<a name="section72226945170128"></a>
## Overview
Defined by the Mobile Industry Processor Interface \(MIPI\) Alliance, the Camera Serial Interface \(CSI\) is a specification that allows data to be transmitted from the camera to the host processor on mobile platforms. In the Hardware Driver Foundation \(HDF\), the MIPI CSI module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS that does not distinguish the user mode and the kernel mode. In the service-free mode, DevHandle \(a void pointer\) directly points to the kernel-mode address of the device object.
The Camera Serial Interface (CSI), defined by the Mobile Industry Processor Interface (MIPI) Alliance, allows data to be transmitted from the camera to the host processor on mobile platforms. In the Hardware Driver Foundation (HDF), the MIPI CSI module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the operating system (OS) that does not distinguish the user mode and the kernel mode. In the service-free mode, **DevHandle** (a void pointer) directly points to the kernel-mode address of the device object.
**Figure 1** Service-free mode<a name="fig260692723120"></a>
**Figure 1** Service-free mode
![](figures/service-free-mode.png "Service-free mode")
![image1](figures/service-free-mode.png "service-free-mode")
## Available APIs<a name="section735525713405"></a>
## Available APIs
MipiCsiCntlrMethod:
**MipiCsiCntlrMethod**:
```
```c
struct MipiCsiCntlrMethod {
int32_t (*setComboDevAttr)(struct MipiCsiCntlr *cntlr, ComboDevAttr *pAttr);
int32_t (*setPhyCmvmode)(struct MipiCsiCntlr *cntlr, uint8_t devno, PhyCmvMode cmvMode);
......@@ -28,204 +28,59 @@ struct MipiCsiCntlrMethod {
int32_t (*unresetSensor)(struct MipiCsiCntlr *cntlr, uint8_t snsResetSource);
};
```
**Table 1** Callbacks for the members in the MipiCsiCntlrMethod structure
<a name="table1233500677170128"></a>
<table><thead align="left"><tr id="row1000451054170128"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="entry1111988081170128p0"><a name="entry1111988081170128p0"></a><a name="entry1111988081170128p0"></a>Callback</p>
</th>
<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.2"><p id="entry1314377643170128p0"><a name="entry1314377643170128p0"></a><a name="entry1314377643170128p0"></a>Input Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.3"><p id="entry102571833170128p0"><a name="entry102571833170128p0"></a><a name="entry102571833170128p0"></a>Output Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.4"><p id="entry259883708170128p0"><a name="entry259883708170128p0"></a><a name="entry259883708170128p0"></a>Return Value</p>
</th>
<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.5"><p id="entry1719007141170128p0"><a name="entry1719007141170128p0"></a><a name="entry1719007141170128p0"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row893348241170128"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="entry2092857420170128p0"><a name="entry2092857420170128p0"></a><a name="entry2092857420170128p0"></a>setComboDevAttr</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p155578927170128"><a name="p155578927170128"></a><a name="p155578927170128"></a><strong id="b2983104693117"><a name="b2983104693117"></a><a name="b2983104693117"></a>cntlr</strong>: structure pointer to the MIPI CSI controller.</p>
<p id="p534134719170128"><a name="p534134719170128"></a><a name="p534134719170128"></a><strong id="b717683263220"><a name="b717683263220"></a><a name="b717683263220"></a>pAttr</strong>: structure pointer to the configuration structure of the MIPI CSI.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="entry1300850044170128p0"><a name="entry1300850044170128p0"></a><a name="entry1300850044170128p0"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="entry1079550609170128p0"><a name="entry1079550609170128p0"></a><a name="entry1079550609170128p0"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="entry1104973652170128p0"><a name="entry1104973652170128p0"></a><a name="entry1104973652170128p0"></a>Sets the MIPI-CSI configuration.</p>
</td>
</tr>
<tr id="row1236584443170128"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="entry1263277119170128p0"><a name="entry1263277119170128p0"></a><a name="entry1263277119170128p0"></a>setPhyCmvmode</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p548503413170128"><a name="p548503413170128"></a><a name="p548503413170128"></a><strong id="b33316314348"><a name="b33316314348"></a><a name="b33316314348"></a>cntlr</strong>: structure pointer to the MIPI CSI controller.</p>
<p id="p1389106408170128"><a name="p1389106408170128"></a><a name="p1389106408170128"></a><strong id="b7288183093611"><a name="b7288183093611"></a><a name="b7288183093611"></a>devno</strong>: Device ID, which is of the uint8_t type.</p>
<p id="p118314402170128"><a name="p118314402170128"></a><a name="p118314402170128"></a><strong id="b1347113393714"><a name="b1347113393714"></a><a name="b1347113393714"></a>cmvMode</strong>: common-mode voltage (CMV) mode.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="entry886884421170128p0"><a name="entry886884421170128p0"></a><a name="entry886884421170128p0"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="entry1542733203170128p0"><a name="entry1542733203170128p0"></a><a name="entry1542733203170128p0"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="entry1506663070170128p0"><a name="entry1506663070170128p0"></a><a name="entry1506663070170128p0"></a>Sets the CMV mode.</p>
</td>
</tr>
<tr id="row1486148936170128"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="entry1589217404170128p0"><a name="entry1589217404170128p0"></a><a name="entry1589217404170128p0"></a>setExtDataType</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p114389566170128"><a name="p114389566170128"></a><a name="p114389566170128"></a><strong id="b34053117344"><a name="b34053117344"></a><a name="b34053117344"></a>cntlr</strong>: structure pointer to the MIPI CSI controller.</p>
<p id="p996608377170128"><a name="p996608377170128"></a><a name="p996608377170128"></a><strong id="b784685684412"><a name="b784685684412"></a><a name="b784685684412"></a>dataType</strong>: structure pointer to the data that defines the YUV, original data formats, and bit depth.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="entry378080489170128p0"><a name="entry378080489170128p0"></a><a name="entry378080489170128p0"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="entry851136224170128p0"><a name="entry851136224170128p0"></a><a name="entry851136224170128p0"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="entry1309676064170128p0"><a name="entry1309676064170128p0"></a><a name="entry1309676064170128p0"></a>Sets the YUV, RAW data format, and bit depth.</p>
</td>
</tr>
<tr id="row692364909170128"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="entry1017488702170128p0"><a name="entry1017488702170128p0"></a><a name="entry1017488702170128p0"></a>setHsMode</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p1054266120170128"><a name="p1054266120170128"></a><a name="p1054266120170128"></a><strong id="b144183117349"><a name="b144183117349"></a><a name="b144183117349"></a>cntlr</strong>: structure pointer to the MIPI CSI controller.</p>
<p id="p1574674418170128"><a name="p1574674418170128"></a><a name="p1574674418170128"></a><strong id="b18748194155516"><a name="b18748194155516"></a><a name="b18748194155516"></a>laneDivideMode</strong>: lane mode.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="entry1749069145170128p0"><a name="entry1749069145170128p0"></a><a name="entry1749069145170128p0"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="entry1237801346170128p0"><a name="entry1237801346170128p0"></a><a name="entry1237801346170128p0"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="entry1643965522170128p0"><a name="entry1643965522170128p0"></a><a name="entry1643965522170128p0"></a>Sets the MIPI RX lane distribution.</p>
</td>
</tr>
<tr id="row1437392211170128"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="entry80806261170128p0"><a name="entry80806261170128p0"></a><a name="entry80806261170128p0"></a>enableClock</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p867235167170128"><a name="p867235167170128"></a><a name="p867235167170128"></a><strong id="b94263116342"><a name="b94263116342"></a><a name="b94263116342"></a>cntlr</strong>: structure pointer to the MIPI CSI controller.</p>
<p id="p1770663973170128"><a name="p1770663973170128"></a><a name="p1770663973170128"></a><strong id="b1342116531004"><a name="b1342116531004"></a><a name="b1342116531004"></a>comboDev</strong>: channel ID, which is of the uint8_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="entry836736200170128p0"><a name="entry836736200170128p0"></a><a name="entry836736200170128p0"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="entry918324954170128p0"><a name="entry918324954170128p0"></a><a name="entry918324954170128p0"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="entry373275246170128p0"><a name="entry373275246170128p0"></a><a name="entry373275246170128p0"></a>Enables the MIPI clock.</p>
</td>
</tr>
<tr id="row1944617165170128"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="entry1879109927170128p0"><a name="entry1879109927170128p0"></a><a name="entry1879109927170128p0"></a>disableClock</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p252627163170128"><a name="p252627163170128"></a><a name="p252627163170128"></a><strong id="b343103114343"><a name="b343103114343"></a><a name="b343103114343"></a>cntlr</strong>: structure pointer to the MIPI CSI controller.</p>
<p id="p573650189170128"><a name="p573650189170128"></a><a name="p573650189170128"></a><strong id="b1747970172618"><a name="b1747970172618"></a><a name="b1747970172618"></a>comboDev</strong>: channel ID, which is of the uint8_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="entry8107921170128p0"><a name="entry8107921170128p0"></a><a name="entry8107921170128p0"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="entry349207958170128p0"><a name="entry349207958170128p0"></a><a name="entry349207958170128p0"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="entry693552037170128p0"><a name="entry693552037170128p0"></a><a name="entry693552037170128p0"></a>Disables the MIPI clock.</p>
</td>
</tr>
<tr id="row168452313170128"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="entry536818735170128p0"><a name="entry536818735170128p0"></a><a name="entry536818735170128p0"></a>resetRx</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p1214231503170128"><a name="p1214231503170128"></a><a name="p1214231503170128"></a><strong id="b1043031153417"><a name="b1043031153417"></a><a name="b1043031153417"></a>cntlr</strong>: structure pointer to the MIPI CSI controller.</p>
<p id="p104793304170128"><a name="p104793304170128"></a><a name="p104793304170128"></a><strong id="b597920533269"><a name="b597920533269"></a><a name="b597920533269"></a>comboDev</strong>: channel ID, which is of the uint8_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="entry349755171170128p0"><a name="entry349755171170128p0"></a><a name="entry349755171170128p0"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="entry608378681170128p0"><a name="entry608378681170128p0"></a><a name="entry608378681170128p0"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="entry1692819512170128p0"><a name="entry1692819512170128p0"></a><a name="entry1692819512170128p0"></a>Resets the MIPI RX.</p>
</td>
</tr>
<tr id="row812174477170128"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="entry677771062170128p0"><a name="entry677771062170128p0"></a><a name="entry677771062170128p0"></a>unresetRx</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p1883220887170128"><a name="p1883220887170128"></a><a name="p1883220887170128"></a><strong id="b1202156153016"><a name="b1202156153016"></a><a name="b1202156153016"></a>cntlr</strong>: structure pointer to the MIPI CSI controller.</p>
<p id="p114324757170128"><a name="p114324757170128"></a><a name="p114324757170128"></a><strong id="b105520153110"><a name="b105520153110"></a><a name="b105520153110"></a>comboDev</strong>: channel ID, which is of the uint8_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="entry2088687179170128p0"><a name="entry2088687179170128p0"></a><a name="entry2088687179170128p0"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="entry250678538170128p0"><a name="entry250678538170128p0"></a><a name="entry250678538170128p0"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="entry1714667992170128p0"><a name="entry1714667992170128p0"></a><a name="entry1714667992170128p0"></a>Deasserts the reset of the MIPI RX.</p>
</td>
</tr>
<tr id="row1282919412170128"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="entry204916079170128p0"><a name="entry204916079170128p0"></a><a name="entry204916079170128p0"></a>enableSensorClock</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p217879421170128"><a name="p217879421170128"></a><a name="p217879421170128"></a><strong id="b197181237203211"><a name="b197181237203211"></a><a name="b197181237203211"></a>cntlr</strong>: structure pointer to the MIPI CSI controller.</p>
<p id="p2098908158170128"><a name="p2098908158170128"></a><a name="p2098908158170128"></a><strong id="b12861154993218"><a name="b12861154993218"></a><a name="b12861154993218"></a>snsClkSource</strong>: number of the clock signal cable of the sensor, which is of the uint8_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="entry1290595383170128p0"><a name="entry1290595383170128p0"></a><a name="entry1290595383170128p0"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="entry1313850176170128p0"><a name="entry1313850176170128p0"></a><a name="entry1313850176170128p0"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="entry384362703170128p0"><a name="entry384362703170128p0"></a><a name="entry384362703170128p0"></a>Enables the MIPI sensor clock.</p>
</td>
</tr>
<tr id="row1992432516170128"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="entry980444503170128p0"><a name="entry980444503170128p0"></a><a name="entry980444503170128p0"></a>disableSensorClock</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p1996780281170128"><a name="p1996780281170128"></a><a name="p1996780281170128"></a><strong id="b4445316347"><a name="b4445316347"></a><a name="b4445316347"></a>cntlr</strong>: structure pointer to the MIPI CSI controller.</p>
<p id="p2021170726170128"><a name="p2021170726170128"></a><a name="p2021170726170128"></a><strong id="b17971423820"><a name="b17971423820"></a><a name="b17971423820"></a>snsClkSource</strong>: number of the clock signal cable of the sensor, which is of the uint8_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="entry1694413990170128p0"><a name="entry1694413990170128p0"></a><a name="entry1694413990170128p0"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="entry1647081928170128p0"><a name="entry1647081928170128p0"></a><a name="entry1647081928170128p0"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="entry2011696236170128p0"><a name="entry2011696236170128p0"></a><a name="entry2011696236170128p0"></a>Disables the MIPI sensor clock.</p>
</td>
</tr>
<tr id="row1739370133170128"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="entry386036597170128p0"><a name="entry386036597170128p0"></a><a name="entry386036597170128p0"></a>resetSensor</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p1065048089170128"><a name="p1065048089170128"></a><a name="p1065048089170128"></a><strong id="b19451631183417"><a name="b19451631183417"></a><a name="b19451631183417"></a>cntlr</strong>: structure pointer to the MIPI CSI controller.</p>
<p id="p998202090170128"><a name="p998202090170128"></a><a name="p998202090170128"></a><strong id="b10443111911384"><a name="b10443111911384"></a><a name="b10443111911384"></a>snsClkSource</strong>: number of the clock signal cable of the sensor, which is of the uint8_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="entry173182567170128p0"><a name="entry173182567170128p0"></a><a name="entry173182567170128p0"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="entry879245456170128p0"><a name="entry879245456170128p0"></a><a name="entry879245456170128p0"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="entry944835652170128p0"><a name="entry944835652170128p0"></a><a name="entry944835652170128p0"></a>Resets the sensor.</p>
</td>
</tr>
<tr id="row1197566339170128"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="entry363281016170128p0"><a name="entry363281016170128p0"></a><a name="entry363281016170128p0"></a>unresetSensor</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p416483731170128"><a name="p416483731170128"></a><a name="p416483731170128"></a><strong id="b178488417385"><a name="b178488417385"></a><a name="b178488417385"></a>cntlr</strong>: structure pointer to the MIPI CSI controller.</p>
<p id="p1988272362170128"><a name="p1988272362170128"></a><a name="p1988272362170128"></a><strong id="b6353246183818"><a name="b6353246183818"></a><a name="b6353246183818"></a>snsClkSource</strong>: number of the clock signal cable of the sensor, which is of the uint8_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="entry1658055665170128p0"><a name="entry1658055665170128p0"></a><a name="entry1658055665170128p0"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="entry2142771023170128p0"><a name="entry2142771023170128p0"></a><a name="entry2142771023170128p0"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="entry791107803170128p0"><a name="entry791107803170128p0"></a><a name="entry791107803170128p0"></a>Deasserts the reset of a sensor.</p>
</td>
</tr>
</tbody>
</table>
## How to Develop<a name="section378858277170128"></a>
**Table 1** Description of the callback functions in the MipiCsiCntlrMethod structure
| Function | Input Parameter | Output Parameter| Return Value | Description |
| ------------------ | ------------------------------------------------------------ | ---- | ------------------ | -------------------------- |
| setComboDevAttr | **cntlr**: structure pointer to the MIPI CSI controller.<br>**pAttr**: structure pointer to the MIPI CSI configuration.| – | HDF_STATUS| Sets MIPI CSI attributes. |
| setPhyCmvmode | **cntlr**: structure pointer to the MIPI CSI controller.<br>**devno**: Device number, which is of the uint8_t type.<br>**cmvMode**: common-mode voltage (CMV) mode to set.| – | HDF_STATUS| Sets the CMV mode. |
| setExtDataType | **cntlr**: structure pointer to the MIPI CSI controller.<br>**dataType**: structure pointer to the data that defines the YUV, original data formats, and bit depth.| – | HDF_STATUS| Sets the YUV, RAW data format, and bit depth.|
| setHsMode | **cntlr**: structure pointer to the MIPI CSI controller.<br>**laneDivideMode**: lane mode.| – | HDF_STATUS| Sets the MIPI RX lane distribution. |
| enableClock | **cntlr**: structure pointer to the MIPI CSI controller.<br>**comboDev**: channel number, which is of the uint8_t type.| – | HDF_STATUS| Enables the MIPI clock. |
| disableClock | **cntlr**: structure pointer to the MIPI CSI controller.<br>**comboDev**: channel number, which is of the uint8_t type.| – | HDF_STATUS| Disables the MIPI clock. |
| resetRx | **cntlr**: structure pointer to the MIPI CSI controller.<br>**comboDev**: channel number, which is of the uint8_t type.| – | HDF_STATUS| Resets the MIPI RX. |
| unresetRx | **cntlr**: structure pointer to the MIPI CSI controller.<br>**comboDev**: channel number, which is of the uint8_t type.| – | HDF_STATUS| Deasserts the reset of the MIPI RX. |
| enableSensorClock | **cntlr**: structure pointer to the MIPI CSI controller.<br>**snsClkSource**: number of the clock signal cable of the sensor, which is of the uint8_t type.| – | HDF_STATUS| Enables the MIPI sensor clock. |
| disableSensorClock | **cntlr**: structure pointer to the MIPI CSI controller.<br>**snsClkSource**: number of the clock signal cable of the sensor, which is of the uint8_t type.| – | HDF_STATUS| Disables the MIPI sensor clock. |
| resetSensor | **cntlr**: structure pointer to the MIPI CSI controller.<br>**snsClkSource**: number of the clock signal cable of the sensor, which is of the uint8_t type.| – | HDF_STATUS| Resets a sensor. |
| unresetSensor | **cntlr**: structure pointer to the MIPI CSI controller.<br>**snsClkSource**: number of the clock signal cable of the sensor, which is of the uint8_t type.| – | HDF_STATUS| Deasserts the reset of a sensor. |
## How to Develop
The MIPI CSI module adaptation involves the following steps:
1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF.
- Call **HDF_INIT** to register the **HdfDriverEntry** instance with the HDF.
2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **mipicsi\_config.hcs** file.
- Add the **deviceNode** information to the **device_info.hcs** file.
- (Optional) Add the **mipicsi_config.hcs** file.
3. Instantiate the MIPI CSI controller object.
- Initialize **MipiCsiCntlr**.
- Instantiate **MipiCsiCntlrMethod** in the **MipiCsiCntlr** object.
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>For details about the functions in **MipiCsiCntlrMethod**, see [Available APIs](#available-apis).
For details, see [Available APIs](#available-apis).
4. Debug the driver.
- (Optional) For new drivers, verify the basic functions, for example, the data transmission and the information returned after the **MipiCsiCntlrMethod** instance is attached.
4. \(Optional\) Debug the driver.
For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted.
## Development Example
## Development Example<a name="section2049027816170128"></a>
The following uses **mipi_rx_hi35xx.c** as an example to present the information required for implementing device functions.
The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
1. Generally, you need to configure the device attributes in **busxx\_config.hcs** and add the **deviceNode** information to the **device\_info.hcs** file. The device attribute values are closely related to the default values or value range of the **MipiCsiCntlr** members at the core layer. The **deviceNode** information is related to the driver entry registration.
1. Configure the device attributes in **busxx_config.hcs** and add the **deviceNode** information to the **device_info.hcs** file.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>In this example, the MIPI controller attributes are defined in the source file. If required, add the **deviceMatchAttr** information to **deviceNode** in the **device\_info** file and add the** mipicsi\_config.hcs** file.
The device attribute values are closely related to the default values or value range of the **MipiCsiCntlr** members at the core layer. The **deviceNode** information is related to the driver entry registration.
**device\_info.hcs** configuration reference:
In this example, the MIPI controller attributes are defined in the source file. If required, add the **deviceMatchAttr** information to **deviceNode** in the **device_info** file and add the **mipicsi_config.hcs** file.
```
- **device_info.hcs** configuration example
```c
root {
device_info {
match_attr = "hdf_manager";
......@@ -237,8 +92,8 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents
policy = 0;
priority = 160;
permission = 0644;
moduleName = "HDF_MIPI_RX"; // (Mandatory) Driver name, which must be the same as the moduleName in the driver entry.
serviceName = "HDF_MIPI_RX";// (Mandatory) Unique name of the service published by the driver.
moduleName = "HDF_MIPI_RX"; // (Mandatory) Driver name, which must be the same as moduleName in the driver entry.
serviceName = "HDF_MIPI_RX"; // (Mandatory) Unique name of the service published by the driver.
}
}
}
......@@ -246,13 +101,13 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents
}
```
2. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. The function pointer members of the **HdfDriverEntry** structure are filled by the vendors' operation functions. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
2. Instantiate the driver entry.<br/>The driver entry must be a global variable of the **HdfDriverEntry** type (defined in **hdf_device_desc.h**), and the value of **moduleName** must be the same as that in **device_info.hcs**. The function pointer members in the **HdfDriverEntry** structure are filled by the vendors' operation functions. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, the HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, the HDF calls **Release** to release driver resources and exit.
MIPI CSI driver entry reference:
- MIPI CSI driver entry example
```
```c
struct HdfDriverEntry g_mipiCsiDriverEntry = {
.moduleVersion = 1,
.Init = Hi35xxMipiCsiInit, // See the Init function.
......@@ -262,15 +117,15 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents
HDF_INIT(g_mipiCsiDriverEntry); // Call HDF_INIT to register the driver entry with the HDF.
```
3. Initialize the **MipiCsiCntlr** object at the core layer, including initializing the vendor custom structure \(passing parameters and data\), instantiating **MipiCsiCntlrMethod** \(used to call underlying functions of the driver\) in **MipiCsiCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference:
3. Initialize the **MipiCsiCntlr** object at the core layer, including defining a custom structure (to pass parameters and data) and implementing the **HdfDriverEntry** member functions (**Bind**, **Init**, and **Release**) to instantiate **MipiCsiCntlrMethod** in **MipiCsiCntlr** (so that the underlying driver functions can be called).
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>To the driver, the custom structure carries parameters and data. The values in the **config** file are used to initialize the structure members. In this example, the MIPI CSI attributes are defined in the source file. Therefore, the basic member structure is similar to that of **MipiCsiCntlr**.
- Defining a custom structure
```
To the driver, the custom structure hols parameters and data. The values in the **config** file are used to initialize the structure members. In this example, the MIPI CSI attributes are defined in the source file. Therefore, the basic member structure is similar to that of **MipiCsiCntlr**.
```c
typedef struct {
/** Data type: 8-bit, 10-bit, 12-bit, 14-bit, or 16-bit */
/** The data type can be 8-, 10-, 12-, 14-, or 16-bit. */
DataType inputDataType;
/** MIPI WDM mode */
MipiWdrMode wdrMode;
......@@ -284,12 +139,12 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents
} MipiDevAttr;
typedef struct {
/** Device number. */
/** Device number */
uint8_t devno;
/** Input mode, which can be MIPI, LVDS, sub-LVDS, HiSPi, or DC. */
InputMode inputMode;
MipiDataRate dataRate;
/** Crop area of the MIPI RX device (same as the size of the input image of the sensor). */
/** Crop area of the MIPI RX device (same as the size of the sensor input image) */
ImgRect imgRect;
union {
......@@ -298,7 +153,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents
};
} ComboDevAttr;
// MipiCsiCntlr is the core layer controller structure. Its members are assigned with values by using the Init function.
// MipiCsiCntlr is the core layer controller structure. The Init function assigns values to the members of MipiCsiCntlr.
struct MipiCsiCntlr {
/** Send the service provided by this controller when the driver is bound to the HDF. */
struct IDeviceIoService service;
......@@ -316,14 +171,14 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents
OsalSpinlock ctxLock;
/** Lock method when the controller is managed */
struct OsalMutex lock;
/** Pointer to anonymous data, which is used to store the CSI device structure */
/** Pointer to the anonymous structure that holds the CSI device data */
void *priv;
};
```
- **\(Important\)** Instantiate the callback function structure **MipiCsiCntlrMethod** in **MipiCsiCntlr**. Other members are initialized by using the **Init** function.
- Instantiating **MipiCsiCntlrMethod** in **MipiCsiCntlr** (other members are initialized by **Init**)
```
```c
static struct MipiCsiCntlrMethod g_method = {
.setComboDevAttr = Hi35xxSetComboDevAttr,
.setPhyCmvmode = Hi35xxSetPhyCmvmode,
......@@ -340,61 +195,32 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents
};
```
- Init function
Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **/drivers/framework/include/utils/hdf\_base.h** file.\)
<a name="table683892652170128"></a>
<table><thead align="left"><tr id="row466801181170128"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry433041536170128p0"><a name="entry433041536170128p0"></a><a name="entry433041536170128p0"></a>Status (Value)</p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.2"><p id="entry1260647143170128p0"><a name="entry1260647143170128p0"></a><a name="entry1260647143170128p0"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row2053721693170128"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="entry772353853170128p0"><a name="entry772353853170128p0"></a><a name="entry772353853170128p0"></a>HDF_ERR_INVALID_OBJECT</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="entry891453569170128p0"><a name="entry891453569170128p0"></a><a name="entry891453569170128p0"></a>Invalid object</p>
</td>
</tr>
<tr id="row1654561941170128"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="entry1037876509170128p0"><a name="entry1037876509170128p0"></a><a name="entry1037876509170128p0"></a>HDF_ERR_MALLOC_FAIL</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="entry1354763041170128p0"><a name="entry1354763041170128p0"></a><a name="entry1354763041170128p0"></a>Failed to allocate memory</p>
</td>
</tr>
<tr id="row515913237170128"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="entry1517991694170128p0"><a name="entry1517991694170128p0"></a><a name="entry1517991694170128p0"></a>HDF_ERR_INVALID_PARAM</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="entry784824354170128p0"><a name="entry784824354170128p0"></a><a name="entry784824354170128p0"></a>Invalid parameter</p>
</td>
</tr>
<tr id="row1055228061170128"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="entry771111180170128p0"><a name="entry771111180170128p0"></a><a name="entry771111180170128p0"></a>HDF_ERR_IO</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="entry1302592910170128p0"><a name="entry1302592910170128p0"></a><a name="entry1302592910170128p0"></a>I/O error</p>
</td>
</tr>
<tr id="row1131544928170128"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="entry1360197988170128p0"><a name="entry1360197988170128p0"></a><a name="entry1360197988170128p0"></a>HDF_SUCCESS</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="entry1609403118170128p0"><a name="entry1609403118170128p0"></a><a name="entry1609403118170128p0"></a>Operation successful</p>
</td>
</tr>
<tr id="row1247344727170128"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="entry816278864170128p0"><a name="entry816278864170128p0"></a><a name="entry816278864170128p0"></a>HDF_FAILURE</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="entry814861870170128p0"><a name="entry814861870170128p0"></a><a name="entry814861870170128p0"></a>Operation failed</p>
</td>
</tr>
</tbody>
</table>
Function description:
Connects to the **MipiCsiCntlrMethod** instance, calls **MipiCsiRegisterCntlr**, and performs other vendor-defined initialization operations.
- Init function
```
**Input parameter**:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information.
**Return value**:
HDF_STATUS<br/>The table below describes some status. For more information, see **HDF_STATUS** in the **/drivers/framework/include/utils/hdf_base.h** file.
| Status | Description |
| :--------------------- | :----------: |
| HDF_ERR_INVALID_OBJECT | Invalid object. |
| HDF_ERR_MALLOC_FAIL | Failed to allocate memory.|
| HDF_ERR_INVALID_PARAM | Invalid parameter. |
| HDF_ERR_IO | I/O error. |
| HDF_SUCCESS | Operation successful. |
| HDF_FAILURE | Operation failed. |
**Function description**:
Attaches the **MipiCsiCntlrMethod** instance, calls **MipiCsiRegisterCntlr**, and initializes the custom structure.
```c
static int32_t Hi35xxMipiCsiInit(struct HdfDeviceObject *device)
{
int32_t ret;
......@@ -403,8 +229,8 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents
g_mipiCsi.priv = NULL; // g_mipiTx is a global variable defined.
// static struct MipiCsiCntlr g_mipiCsi = {
// .devNo = 0
// };
g_mipiCsi.ops = &g_method; // Connect to the MipiCsiCntlrMethod instance.
//};
g_mipiCsi.ops = &g_method; // Attach the MipiCsiCntlrMethod instance.
#ifdef CONFIG_HI_PROC_SHOW_SUPPORT
g_mipiCsi.debugs = &g_debugMethod;
#endif
......@@ -433,19 +259,19 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents
return ret;
}
// mipi_csi_core.c, core layer file.
// mipi_csi_core.c file
int32_t MipiCsiRegisterCntlr(struct MipiCsiCntlr *cntlr, struct HdfDeviceObject *device)
{
...
// Define the global variable static struct MipiCsiHandle g_mipiCsihandle[MAX_CNTLR_CNT];
// Global variable static struct MipiCsiHandle g_mipiCsihandle[MAX_CNTLR_CNT];
if (g_mipiCsihandle[cntlr->devNo].cntlr == NULL) {
(void)OsalMutexInit(&g_mipiCsihandle[cntlr->devNo].lock);
(void)OsalMutexInit(&(cntlr->lock));
g_mipiCsihandle[cntlr->devNo].cntlr = cntlr; // Initialize MipiCsiHandle.
g_mipiCsihandle[cntlr->devNo].priv = NULL;
cntlr->device = device; // Enable conversion between HdfDeviceObject and MipiCsiHandle.
device->service = &(cntlr->service); // Enable conversion between HdfDeviceObject and MipiCsiHandle.
cntlr->device = device; // Prerequisites for conversion between HdfDeviceObject and MipiCsiHandle
device->service = &(cntlr->service); // Prerequisites for conversion between HdfDeviceObject and MipiCsiHandle.
cntlr->priv = NULL;
HDF_LOGI("%s: success.", __func__);
......@@ -457,21 +283,23 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents
}
```
- Release function
- Release function
Input parameters:
**Input parameter**:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information.
Return values:
**Return value**:
No value is returned.
Function description:
**Function description**:
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations.
Releases the memory and deletes the controller. This function assigns values to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources.
```
All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the value assignment operations.
```c
static void Hi35xxMipiCsiRelease(struct HdfDeviceObject *device)
{
struct MipiCsiCntlr *cntlr = NULL;
......@@ -484,7 +312,7 @@ The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents
#ifdef MIPICSI_VFS_SUPPORT
MipiCsiDevModuleExit(cntlr->devNo);
#endif
MipiRxDrvExit(); // (Mandatory) Release the resources occupied by the vendor's devices.
MipiRxDrvExit(); // (Mandatory) Release the resources occupied by vendor devices.
MipiCsiUnregisterCntlr(&g_mipiCsi); // Null function
g_mipiCsi.priv = NULL;
......
# MMC<a name="EN-US_TOPIC_0000001153669000"></a>
# MMC
## Overview<a name="section1846388309162704"></a>
In the Hardware Driver Foundation \(HDF\) framework, the MultiMedia Card \(MMC\) uses the independent service mode for API adaptation. In this mode, each device independently publishes a device service to handle external access requests. After receiving an access request from an API, the device manager extracts the parameters in the request to call the internal method of the target device. In the independent service mode, the service management capabilities of the HDFDeviceManager can be directly used. However, you need to configure a device node for each device, which increases the memory usage.
## Overview
**Figure 1** Independent service mode<a name="fig19517114132810"></a>
![](figures/independent-service-mode.png "independent-service-mode")
In the Hardware Driver Foundation (HDF), the MultiMedia Card (MMC) uses the independent service mode for API adaptation. In this mode, each device independently publishes a service to process external access requests. When receiving an access request, the HDF DeviceManager extracts parameters from the request to call the internal APIs of the target device. In the independent service mode, the HDF DeviceManager provides service management capabilities. However, you need to configure a node for each device to increase memory resources.
## Available APIs<a name="section752964871810"></a>
**Figure 1** Independent service mode
![image](figures/independent-service-mode.png "MMC independent service mode")
## Available APIs
**MmcCntlrOps**:
MmcCntlrOps
```
struct MmcCntlrOps {
......@@ -31,214 +35,77 @@ struct MmcCntlrOps {
};
```
**Table 1** Callbacks for the members in the MmcCntlrOps structure
<a name="table99129433019"></a>
<table><thead align="left"><tr id="row1891214163012"><th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.1"><p id="p79129483017"><a name="p79129483017"></a><a name="p79129483017"></a>Callback</p>
</th>
<th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.2"><p id="p1591213403019"><a name="p1591213403019"></a><a name="p1591213403019"></a>Input Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.3"><p id="p491312483012"><a name="p491312483012"></a><a name="p491312483012"></a>Return Value</p>
</th>
<th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.4"><p id="p8913144203017"><a name="p8913144203017"></a><a name="p8913144203017"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row4913844307"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p17913149309"><a name="p17913149309"></a><a name="p17913149309"></a>doRequest</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p359655512340"><a name="p359655512340"></a><a name="p359655512340"></a><strong id="b1596155533411"><a name="b1596155533411"></a><a name="b1596155533411"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
<p id="p159131449308"><a name="p159131449308"></a><a name="p159131449308"></a><strong id="b71781053113715"><a name="b71781053113715"></a><a name="b71781053113715"></a>cmd</strong>: structure pointer to the input command.</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p1291519413308"><a name="p1291519413308"></a><a name="p1291519413308"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p3915048309"><a name="p3915048309"></a><a name="p3915048309"></a>Processes the request.</p>
</td>
</tr>
<tr id="row17915124113014"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p69152416307"><a name="p69152416307"></a><a name="p69152416307"></a>setClock</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p12397758163416"><a name="p12397758163416"></a><a name="p12397758163416"></a><strong id="b2397155816345"><a name="b2397155816345"></a><a name="b2397155816345"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
<p id="p119153413013"><a name="p119153413013"></a><a name="p119153413013"></a><strong id="b13651101617393"><a name="b13651101617393"></a><a name="b13651101617393"></a>clock</strong>: input clock value.</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p79153417302"><a name="p79153417302"></a><a name="p79153417302"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p1291614183010"><a name="p1291614183010"></a><a name="p1291614183010"></a>Sets the clock frequency.</p>
</td>
</tr>
<tr id="row19168433011"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p1391614416305"><a name="p1391614416305"></a><a name="p1391614416305"></a>setPowerMode</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p349710303139"><a name="p349710303139"></a><a name="p349710303139"></a><strong id="b749713013132"><a name="b749713013132"></a><a name="b749713013132"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
<p id="p99161341305"><a name="p99161341305"></a><a name="p99161341305"></a><strong id="b1355614134405"><a name="b1355614134405"></a><a name="b1355614134405"></a>mode</strong>: power consumption mode. It is an enumerated value (see MmcPowerMode).</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p1091674183020"><a name="p1091674183020"></a><a name="p1091674183020"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p1191617420307"><a name="p1191617420307"></a><a name="p1191617420307"></a>Sets the power consumption mode.</p>
</td>
</tr>
<tr id="row291620463018"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p291612453018"><a name="p291612453018"></a><a name="p291612453018"></a>setBusWidth</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p52591598350"><a name="p52591598350"></a><a name="p52591598350"></a><strong id="b225999203512"><a name="b225999203512"></a><a name="b225999203512"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
<p id="p11916245309"><a name="p11916245309"></a><a name="p11916245309"></a><strong id="b24742024134111"><a name="b24742024134111"></a><a name="b24742024134111"></a>width</strong>: bus width. It is an enumerated value (see MmcBusWidth).</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p1491610415305"><a name="p1491610415305"></a><a name="p1491610415305"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p19916147304"><a name="p19916147304"></a><a name="p19916147304"></a>Sets the bus width.</p>
</td>
</tr>
<tr id="row1916742301"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p3916104143014"><a name="p3916104143014"></a><a name="p3916104143014"></a>setBusTiming</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p109861912123517"><a name="p109861912123517"></a><a name="p109861912123517"></a><strong id="b39864125357"><a name="b39864125357"></a><a name="b39864125357"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
<p id="p591710419302"><a name="p591710419302"></a><a name="p591710419302"></a><strong id="b1067164920426"><a name="b1067164920426"></a><a name="b1067164920426"></a>timing</strong>: bus timing. It is an enumerated value (see MmcBusTiming).</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p14917154123017"><a name="p14917154123017"></a><a name="p14917154123017"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p1991814443016"><a name="p1991814443016"></a><a name="p1991814443016"></a>Sets the bus timing.</p>
</td>
</tr>
<tr id="row199186423012"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p991810414305"><a name="p991810414305"></a><a name="p991810414305"></a>setSdioIrq</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p207324169351"><a name="p207324169351"></a><a name="p207324169351"></a><strong id="b11731716183510"><a name="b11731716183510"></a><a name="b11731716183510"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
<p id="p16918844305"><a name="p16918844305"></a><a name="p16918844305"></a><strong id="b49304428454"><a name="b49304428454"></a><a name="b49304428454"></a>enable</strong>: specifies whether to enable interrupt.</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p17918204193011"><a name="p17918204193011"></a><a name="p17918204193011"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p1191813416305"><a name="p1191813416305"></a><a name="p1191813416305"></a>Enables or disables Secure Digital Input Output (SDIO) interrupt.</p>
</td>
</tr>
<tr id="row139181453012"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p491874193011"><a name="p491874193011"></a><a name="p491874193011"></a>hardwareReset</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p12918114163011"><a name="p12918114163011"></a><a name="p12918114163011"></a><strong id="b127774583476"><a name="b127774583476"></a><a name="b127774583476"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p4918244309"><a name="p4918244309"></a><a name="p4918244309"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p11919243306"><a name="p11919243306"></a><a name="p11919243306"></a>Resets hardware.</p>
</td>
</tr>
<tr id="row169195410309"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p89191746303"><a name="p89191746303"></a><a name="p89191746303"></a>systemInit</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p8919441302"><a name="p8919441302"></a><a name="p8919441302"></a><strong id="b296543474814"><a name="b296543474814"></a><a name="b296543474814"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p199191941307"><a name="p199191941307"></a><a name="p199191941307"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p391919473014"><a name="p391919473014"></a><a name="p391919473014"></a>Performs system initialization.</p>
</td>
</tr>
<tr id="row159191423012"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p189194417307"><a name="p189194417307"></a><a name="p189194417307"></a>setEnhanceSrobe</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p684922173510"><a name="p684922173510"></a><a name="p684922173510"></a><strong id="b1184122212354"><a name="b1184122212354"></a><a name="b1184122212354"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
<p id="p1191910419304"><a name="p1191910419304"></a><a name="p1191910419304"></a><strong id="b17674159184914"><a name="b17674159184914"></a><a name="b17674159184914"></a>enable</strong>: specifies whether to enable the enhanced strobe feature.</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p69194473011"><a name="p69194473011"></a><a name="p69194473011"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p091904143019"><a name="p091904143019"></a><a name="p091904143019"></a>Sets the enhanced strobe feature.</p>
</td>
</tr>
<tr id="row109197416305"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p791917443010"><a name="p791917443010"></a><a name="p791917443010"></a>switchVoltage</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p180311317351"><a name="p180311317351"></a><a name="p180311317351"></a><strong id="b2803231173514"><a name="b2803231173514"></a><a name="b2803231173514"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
<p id="p1591912415304"><a name="p1591912415304"></a><a name="p1591912415304"></a><strong id="b5411538185218"><a name="b5411538185218"></a><a name="b5411538185218"></a>volt</strong>: voltage, which can be 3.3 V, 1.8 V, or 1.2 V. It is an enumerated value.</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p59196416307"><a name="p59196416307"></a><a name="p59196416307"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p169207416301"><a name="p169207416301"></a><a name="p169207416301"></a>Sets the voltage.</p>
</td>
</tr>
<tr id="row1992015417301"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p1892014463010"><a name="p1892014463010"></a><a name="p1892014463010"></a>devReadOnly</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p1392011411309"><a name="p1392011411309"></a><a name="p1392011411309"></a><strong id="b20848102414403"><a name="b20848102414403"></a><a name="b20848102414403"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p89207418304"><a name="p89207418304"></a><a name="p89207418304"></a>Boolean</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p7920847301"><a name="p7920847301"></a><a name="p7920847301"></a>Checks whether the device is read-only.</p>
</td>
</tr>
<tr id="row1092019483018"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p1092034103011"><a name="p1092034103011"></a><a name="p1092034103011"></a>cardPluged</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p2920144123010"><a name="p2920144123010"></a><a name="p2920144123010"></a><strong id="b1685142434016"><a name="b1685142434016"></a><a name="b1685142434016"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p2092014411305"><a name="p2092014411305"></a><a name="p2092014411305"></a>Boolean</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p1892094153017"><a name="p1892094153017"></a><a name="p1892094153017"></a>Checks whether the device is removed.</p>
</td>
</tr>
<tr id="row892018413013"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p39201146309"><a name="p39201146309"></a><a name="p39201146309"></a>devBusy</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p9920124193013"><a name="p9920124193013"></a><a name="p9920124193013"></a><strong id="b1885213240408"><a name="b1885213240408"></a><a name="b1885213240408"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p1992112419305"><a name="p1992112419305"></a><a name="p1992112419305"></a>Boolean</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p69211417302"><a name="p69211417302"></a><a name="p69211417302"></a>Checks whether the device is engaged.</p>
</td>
</tr>
<tr id="row71064053613"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p1511114015361"><a name="p1511114015361"></a><a name="p1511114015361"></a>tune</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p4972240153511"><a name="p4972240153511"></a><a name="p4972240153511"></a><strong id="b1997244017354"><a name="b1997244017354"></a><a name="b1997244017354"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
<p id="p5116409364"><a name="p5116409364"></a><a name="p5116409364"></a><strong id="b2286168195617"><a name="b2286168195617"></a><a name="b2286168195617"></a>cmdCode</strong>: command code of the uint32_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p711440123610"><a name="p711440123610"></a><a name="p711440123610"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p1411184011368"><a name="p1411184011368"></a><a name="p1411184011368"></a>Tunes</p>
</td>
</tr>
<tr id="row1559214410366"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p1559364493618"><a name="p1559364493618"></a><a name="p1559364493618"></a>rescanSdioDev</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p165931944133618"><a name="p165931944133618"></a><a name="p165931944133618"></a><strong id="b0854424164010"><a name="b0854424164010"></a><a name="b0854424164010"></a>cntlr</strong>: structure pointer to the MMC controller at the core layer.</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.3 "><p id="p15593184493610"><a name="p15593184493610"></a><a name="p15593184493610"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.4 "><p id="p359384473615"><a name="p359384473615"></a><a name="p359384473615"></a>Scans and adds an SDIO device.</p>
</td>
</tr>
</tbody>
</table>
## How to Develop<a name="section1617495117162704"></a>
**Table 1** Description of callback functions in MmcCntlrOps
| Function| Input Parameter| Return Value| Description|
| -------- | -------- | -------- | -------- |
| doRequest | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**cmd**: structure pointer to the command to execute.| HDF_STATUS| Processes the request.|
| setClock | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**clock**: clock frequency to set.| HDF_STATUS| Sets the clock frequency.|
| setPowerMode | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**mode**: power consumption mode, which is an enumerated value.| HDF_STATUS| Sets the power consumption mode.|
| setBusWidth | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**width**: bus width, which is an enumerated value.| HDF_STATUS| Sets the bus width.|
| setBusTiming | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**timing**: bus timing, which is an enumerated value.| HDF_STATUS| Sets the bus timing.|
| setSdioIrq | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**enable**: whether to enable Secure Digital Input Output (SDIO) interrupts.| HDF_STATUS| Enables or disables SDIO interrupts.|
| hardwareReset | **cntlr**: structure pointer to the MMC controller at the core layer.| HDF_STATUS| Resets hardware.|
| systemInit | **cntlr**: structure pointer to the MMC controller at the core layer.| HDF_STATUS| Performs system initialization.|
| setEnhanceSrobe | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**enable**: whether to enable the enhanced strobe feature.| HDF_STATUS| Sets the enhanced strobe feature.|
| switchVoltage | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**volt**: voltage to set, which can be 3.3 V, 1.8 V, or 1.2 V.| HDF_STATUS| Sets the voltage.|
| devReadOnly | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is read-only.|
| cardPluged | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is removed.|
| devBusy | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is being used.|
| tune | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**cmdCode**: command code of the uint32_t type.| HDF_STATUS| Tunes the oscillator circuit frequency. |
| rescanSdioDev | **cntlr**: structure pointer to the MMC controller at the core layer.| HDF_STATUS| Scans and adds an SDIO device.|
## How to Develop
The MMC module adaptation involves the following steps:
1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF framework.
- Call **HDF_INIT** to register the **HdfDriverEntry** instance with the HDF.
2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **mmc\_config.hcs** file.
- Add the **deviceNode** information to the **device_info.hcs** file.
- (Optional) Add the **mmc_config.hcs** file.
3. Instantiate the MMC controller object.
- Initialize **MmcCntlr**.
- Instantiate **MmcCntlrOps** in the **MmcCntlr** object.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> For details about the functions in **MmcCntlrOps**, see [Available APIs](#available-apis).
For details, see [Available APIs](#available-apis).
4. Debug the driver.
4. \(Optional\) Debug the driver.
For new drivers, verify basic functions, for example, verify the information returned after the mount operation and whether the device starts successfully.
(Optional) For new drivers, verify the basic functions, for example, verify the information returned after the **MmcCntlrOps** instance is attached and whether the device starts successfully.
## Development Example<a name="section1220893490162704"></a>
## Development Example
The following uses **himci.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
The following uses **himci.c** as an example to present the information required for implementing device functions.
1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
1. Instantiate the driver entry.<br/>The driver entry must be a global variable of the **HdfDriverEntry** type (defined in **hdf_device_desc.h**), and the value of **moduleName** must be the same as that in **device_info.hcs**. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exit.
Generally, the HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, the HDF calls **Release** to release driver resources and exit.
- MMC driver entry reference
MMC driver entry example:
```
struct HdfDriverEntry g_mmcDriverEntry = {
.moduleVersion = 1,
.Bind = HimciMmcBind, // See the Bind function.
.Init = HimciMmcInit, // See the Init function.
.Release = HimciMmcRelease, //See the Release function.
.Release = HimciMmcRelease, // See the Release function.
.moduleName = "hi3516_mmc_driver",// (Mandatory) The value must be the same as that of moduleName in the .hcs file.
};
HDF_INIT(g_mmcDriverEntry); // Call HDF_INIT to register the driver entry with the HDF framework.
HDF_INIT(g_mmcDriverEntry); // Call HDF_INIT to register the driver entry with the HDF.
```
2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **mmc\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the default values or value ranges of the **MmcCntlr** members at the core layer.
2. Add the **deviceNode** information to the **device_info.hcs** file and configure the device attributes in the **mmc_config.hcs** file.
If there are multiple devices, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **mmc\_config** file.
The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the default values or value ranges of the **MmcCntlr** members at the core layer. If there are multiple devices, you need to add the **deviceNode** information to the **device_info** file and add the device attributes to the **mmc_config** file for each device.
- **device_info.hcs** configuration example
- **device\_info.hcs** configuration reference
```
root {
......@@ -252,9 +119,9 @@ The following uses **himci.c** as an example to present the contents that need t
policy = 2;
priority = 10;
permission = 0644;
moduleName = "hi3516_mmc_driver"; // (Mandatory) Driver name, which must be the same as the moduleName in the driver entry.
serviceName = "HDF_PLATFORM_MMC_0"; // (Mandatory) Unique name of the service published by the driver
deviceMatchAttr = "hi3516_mmc_emmc";// (Mandatory) Used to configure the private data of the controller. The value must be the same as the controller in mmc_config.hcs.
moduleName = "hi3516_mmc_driver"; // (Mandatory) Driver name, which must be the same as moduleName in the driver entry.
serviceName = "HDF_PLATFORM_MMC_0"; // (Mandatory) Unique name of the service published by the driver.
deviceMatchAttr = "hi3516_mmc_emmc";// (Mandatory) Private data of the controller. The value must be the same as the controller information in mmc_config.hcs.
}
device1 :: deviceNode {
policy = 1;
......@@ -262,7 +129,7 @@ The following uses **himci.c** as an example to present the contents that need t
permission = 0644;
moduleName = "hi3516_mmc_driver";
serviceName = "HDF_PLATFORM_MMC_1";
deviceMatchAttr = "hi3516_mmc_sd"; // Indicates an SD.
deviceMatchAttr = "hi3516_mmc_sd"; // The MMC is an SD card.
}
device2 :: deviceNode {
policy = 1;
......@@ -270,7 +137,7 @@ The following uses **himci.c** as an example to present the contents that need t
permission = 0644;
moduleName = "hi3516_mmc_driver";
serviceName = "HDF_PLATFORM_MMC_2";
deviceMatchAttr = "hi3516_mmc_sdio";// Indicates an SDIO.
deviceMatchAttr = "hi3516_mmc_sdio";// The MMC is an SDIO card.
}
}
}
......@@ -278,13 +145,14 @@ The following uses **himci.c** as an example to present the contents that need t
}
```
- **mmc\_config.hcs** configuration reference
- **mmc_config.hcs** configuration example
```
root {
platform {
mmc_config {
template mmc_controller {// Template configuration. In the template, you can configure the common parameters shared by service nodes.
template mmc_controller { // Template configuration. In the template, you can configure the common parameters shared by device nodes.
match_attr = "";
voltDef = 0; // 3.3V
freqMin = 50000; // (Mandatory) Minimum frequency
......@@ -298,7 +166,7 @@ The following uses **himci.c** as an example to present the contents that need t
hostId = 0; // (Mandatory) Host ID
regBasePhy = 0x10020000;// (Mandatory) Physical base address of the register
irqNum = 63; // (Mandatory) Interrupt number
devType = 2; // (Mandatory) Device mode, which can be eMMC, SD, SDIO, or COMBO
devType = 2; // (Mandatory) Device type, which can be eMMC, SD, SDIO, or COMBO
caps = 0x0001e045; // (Mandatory) Attribute register. For details, see MmcCaps in mmc_caps.h.
}
controller_0x10100000 :: mmc_controller {
......@@ -306,7 +174,7 @@ The following uses **himci.c** as an example to present the contents that need t
hostId = 0;
regBasePhy = 0x10100000;
irqNum = 96;
devType = 0; // The value 0 indicates an eMMC.
devType = 0; // The MMC is an eMMC card.
caps = 0xd001e045;
caps2 = 0x60;
}
......@@ -315,7 +183,7 @@ The following uses **himci.c** as an example to present the contents that need t
hostId = 1;
regBasePhy = 0x100f0000;
irqNum = 62;
devType = 1; // The value 1 indicates an SD card.
devType = 1; // The MMC is an SD card.
caps = 0xd001e005;
}
controller_0x10020000 :: mmc_controller {
......@@ -323,7 +191,7 @@ The following uses **himci.c** as an example to present the contents that need t
hostId = 2;
regBasePhy = 0x10020000;
irqNum = 63;
devType = 2; // The value 2 indicates an SDIO device.
devType = 2; // The MMC is an SDIO card.
caps = 0x0001e04d;
}
}
......@@ -331,16 +199,17 @@ The following uses **himci.c** as an example to present the contents that need t
}
```
3. Initialize the **MmcCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **MmcCntlrOps** \(used to call underlying functions of the driver\) in **MmcCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference
3. Initialize the **MmcCntlr** object at the core layer, including defining a custom structure (to pass parameters and data) and implementing the **HdfDriverEntry** member functions (**Bind**, **Init**, and **Release**) to instantiate **MmcCntlrOps** in **MmcCntlr** (so that the underlying driver functions can be called).
- Defining a custom structure
To the driver, the custom structure holds parameters and data. The **DeviceResourceIface** method provided by the HDF reads the values in the **mmc_config.hcs** file to initialize the members in the custom structure and pass important parameters to the **MmcCntlr** object at the core layer.
To the driver, the custom structure carries parameters and data. The values in the **mmc\_config.hcs** file are read by the HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values are also transferred to the objects at the core layer.
```
struct HimciHost {
struct MmcCntlr *mmc;// (Mandatory) Core layer structure
struct MmcCmd *cmd; // (Mandatory) Core layer structure used to transfer commands. For details about related commands, see MmcCmdCode.
//(Optional) Set parameters based on the vendor's requirements.
struct MmcCmd *cmd; // (Mandatory) Core layer structure used to pass commands. For details about related commands, see MmcCmdCode.
//(Optional) Set parameters based on actual requirements.
void *base;
enum HimciPowerStatus powerStatus;
uint8_t *alignedBuff;
......@@ -357,7 +226,7 @@ The following uses **himci.c** as an example to present the contents that need t
bool waitForEvent;
HIMCI_EVENT himciEvent;
};
// MmcCntlr is the core layer controller structure. Its members are assigned with values by using the bind function.
// MmcCntlr is the core layer controller structure. The bind function assigns values to the members of MmcCntlr.
struct MmcCntlr {
struct IDeviceIoService service;
struct HdfDeviceObject *hdfDevObj;
......@@ -386,7 +255,8 @@ The following uses **himci.c** as an example to present the contents that need t
};
```
- Instantiate the callback function structure **MmcCntlrOps** in **MmcCntlr**. Other members are initialized by using the **Bind** function.
- Instantiating **MmcCntlrOps** in **MmcCntlr** (other members are initialized by **Bind**)
```
static struct MmcCntlrOps g_himciHostOps = {
......@@ -407,61 +277,30 @@ The following uses **himci.c** as an example to present the contents that need t
.rescanSdioDev = HimciRescanSdioDev,
};
```
- **Bind** function
- Bind function
Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\)
<a name="table1428218958162704"></a>
<table><thead align="left"><tr id="row1723943104162704"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="entry136979408162704p0"><a name="entry136979408162704p0"></a><a name="entry136979408162704p0"></a>Status (Value)</p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.2"><p id="entry1590766658162704p0"><a name="entry1590766658162704p0"></a><a name="entry1590766658162704p0"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row408410040162704"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="entry1337150412162704p0"><a name="entry1337150412162704p0"></a><a name="entry1337150412162704p0"></a>HDF_ERR_INVALID_OBJECT</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="entry2061632106162704p0"><a name="entry2061632106162704p0"></a><a name="entry2061632106162704p0"></a>Invalid controller object</p>
</td>
</tr>
<tr id="row160841211162704"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="entry1173668571162704p0"><a name="entry1173668571162704p0"></a><a name="entry1173668571162704p0"></a>HDF_ERR_MALLOC_FAIL</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="entry74350097162704p0"><a name="entry74350097162704p0"></a><a name="entry74350097162704p0"></a>Failed to allocate memory</p>
</td>
</tr>
<tr id="row1596857798162704"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="entry190784255162704p0"><a name="entry190784255162704p0"></a><a name="entry190784255162704p0"></a>HDF_ERR_INVALID_PARAM</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="entry1070501269162704p0"><a name="entry1070501269162704p0"></a><a name="entry1070501269162704p0"></a>Invalid parameter</p>
</td>
</tr>
<tr id="row1645995958162704"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="entry741922133162704p0"><a name="entry741922133162704p0"></a><a name="entry741922133162704p0"></a>HDF_ERR_IO</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="entry2094504256162704p0"><a name="entry2094504256162704p0"></a><a name="entry2094504256162704p0"></a>I/O error</p>
</td>
</tr>
<tr id="row733220922162704"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="entry1177794681162704p0"><a name="entry1177794681162704p0"></a><a name="entry1177794681162704p0"></a>HDF_SUCCESS</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="entry540896959162704p0"><a name="entry540896959162704p0"></a><a name="entry540896959162704p0"></a>Initialization successful</p>
</td>
</tr>
<tr id="row1890064939162704"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="entry118676812162704p0"><a name="entry118676812162704p0"></a><a name="entry118676812162704p0"></a>HDF_FAILURE</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="entry2078272728162704p0"><a name="entry2078272728162704p0"></a><a name="entry2078272728162704p0"></a>Initialization failed</p>
</td>
</tr>
</tbody>
</table>
Function description:
**Input parameter**:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information.
**Return value**:
HDF_STATUS<br/>The table below describes some status. For more information, see **HDF_STATUS** in the **/drivers/framework/include/utils/hdf_base.h** file.
| Status| Description|
| -------- | -------- |
| HDF_ERR_INVALID_OBJECT | Invalid controller object.|
| HDF_ERR_MALLOC_FAIL | Failed to allocate memory.|
| HDF_ERR_INVALID_PARAM | Invalid parameter.|
| HDF_ERR_IO | I/O error.|
| HDF_SUCCESS | Initialization successful.|
| HDF_FAILURE | Initialization failed.|
**Function description**:
Initializes the custom structure **HimciHost** object and **MmcCntlr**, and calls the **MmcCntlrAdd** function at the core layer. **MmcCntlr**, **HimciHost**, and **HdfDeviceObject** assign values with each other so that other functions can be converted successfully.
```
static int32_t HimciMmcBind(struct HdfDeviceObject *obj)
{
......@@ -471,18 +310,18 @@ The following uses **himci.c** as an example to present the contents that need t
cntlr = (struct MmcCntlr *)OsalMemCalloc(sizeof(struct MmcCntlr));
host = (struct HimciHost *)OsalMemCalloc(sizeof(struct HimciHost));
host->mmc = cntlr; // (Mandatory) Enable conversion between HimciHost and MmcCntlr.
cntlr->priv = (void *)host; // (Mandatory) Enable conversion between HimciHost and MmcCntlr.
cntlr->ops = &g_himciHostOps; // (Mandatory) Connect to the MmcCntlrOps instance.
cntlr->hdfDevObj = obj; // (Mandatory) Enable conversion between HdfDeviceObject and MmcCntlr.
obj->service = &cntlr->service; // (Mandatory) Enable conversion between HdfDeviceObject and MmcCntlr.
ret = MmcCntlrParse(cntlr, obj); // (Mandatory) Initialize cntlr. If the initialization fails, execute goto _ERR.
host->mmc = cntlr; // (Mandatory) Prerequisites for conversion between HimciHost and MmcCntlr.
cntlr->priv = (void *)host; // (Mandatory) Prerequisites for conversion between HimciHost and MmcCntlr.
cntlr->ops = &g_himciHostOps; // (Mandatory) Attach the MmcCntlrOps instance.
cntlr->hdfDevObj = obj; // (Mandatory) Prerequisites for conversion between HdfDeviceObject and MmcCntlr.
obj->service = &cntlr->service; // (Mandatory) Prerequisites for conversion between HdfDeviceObject and MmcCntlr.
ret = MmcCntlrParse(cntlr, obj); // (Mandatory) Initialize MmcCntlr. If the initialization fails, execute goto _ERR.
...
ret = HimciHostParse(host, obj); // (Mandatory) Initialize the attributes of the host. If the initialization fails, execute goto _ERR.
ret = HimciHostParse(host, obj); // (Mandatory) Initialize HimciHost. If the initialization fails, execute goto _ERR.
...
ret = HimciHostInit(host, cntlr);// Initialization defined by the vendor. If the initialization fails, execute goto _ERR.
ret = HimciHostInit(host, cntlr);// Customized initialization. If the initialization fails, execute goto _ERR.
...
ret = MmcCntlrAdd(cntlr); // Call the function at the core layer. If the function fails to be called, execute goto _ERR.
ret = MmcCntlrAdd(cntlr); // Call the functions at the core layer. If the operation fails, execute goto _ERR.
...
(void)MmcCntlrAddDetectMsgToQueue(cntlr);// Add the card detection message to the queue.
HDF_LOGD("HimciMmcBind: success.");
......@@ -494,19 +333,20 @@ The following uses **himci.c** as an example to present the contents that need t
}
```
- Init function
- **Init** function
**Input parameter**:
Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information.
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
**Return value**:
Return values:
HDF_STATUS
HDF\_STATUS
**Function description**:
Function description:
Implements **ProcMciInit**.
Implements ProcMciInit.
```
static int32_t HimciMmcInit(struct HdfDeviceObject *obj)
......@@ -523,20 +363,20 @@ The following uses **himci.c** as an example to present the contents that need t
return HDF_SUCCESS;
}
```
- **Release** function
- Release function
**Input parameter**:
Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information.
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
**Return value**:
Return values:
No value is returned.
**Function description**:
Function description:
Releases the memory and deletes the controller. This function assigns values to the **Release** function in the driver entry structure. If the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the value assignment operations.
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF framework fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations.
```
static void HimciMmcRelease(struct HdfDeviceObject *obj)
......@@ -545,6 +385,6 @@ The following uses **himci.c** as an example to present the contents that need t
...
cntlr = (struct MmcCntlr *)obj->service;// Forcibly convert HdfDeviceObject to MmcCntlr by using service. For details about the value assignment, see the Bind function.
...
HimciDeleteHost((struct HimciHost *)cntlr->priv);// Memory release function customized by the vendor. A forced conversion from MmcCntlr to HimciHost is involved in the process.
HimciDeleteHost((struct HimciHost *)cntlr->priv);// Customized memory release function. A forced conversion from MmcCntlr to HimciHost is involved in the process.
}
```
# RTC<a name="EN-US_TOPIC_0000001206373007"></a>
## Overview<a name="section104842041574"></a>
The real-time clock \(RTC\) driver provides precise real time for the operating system \(OS\). If the OS is powered off, the RTC driver continues to keep track of the system time using an external battery.
## Available APIs<a name="section20331159102519"></a>
**Table 1** APIs provided by the RTC driver
<a name="table1731550155318"></a>
<table><thead align="left"><tr id="row4419501537"><th class="cellrowborder" valign="top" width="21.902190219021904%" id="mcps1.2.4.1.1"><p id="p641050105320"><a name="p641050105320"></a><a name="p641050105320"></a><strong id="b17744818255"><a name="b17744818255"></a><a name="b17744818255"></a>Capability</strong></p>
</th>
<th class="cellrowborder" valign="top" width="24.98249824982498%" id="mcps1.2.4.1.2"><p id="p54150165315"><a name="p54150165315"></a><a name="p54150165315"></a><strong id="b257315114254"><a name="b257315114254"></a><a name="b257315114254"></a>Function</strong></p>
</th>
<th class="cellrowborder" valign="top" width="53.11531153115312%" id="mcps1.2.4.1.3"><p id="p941150145313"><a name="p941150145313"></a><a name="p941150145313"></a><strong id="b384185962317"><a name="b384185962317"></a><a name="b384185962317"></a>Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row17550163418501"><td class="cellrowborder" rowspan="2" valign="top" width="21.902190219021904%" headers="mcps1.2.4.1.1 "><p id="p11670643205012"><a name="p11670643205012"></a><a name="p11670643205012"></a>RTC handle</p>
</td>
<td class="cellrowborder" valign="top" width="24.98249824982498%" headers="mcps1.2.4.1.2 "><p id="p16550143465015"><a name="p16550143465015"></a><a name="p16550143465015"></a>RtcOpen</p>
</td>
<td class="cellrowborder" valign="top" width="53.11531153115312%" headers="mcps1.2.4.1.3 "><p id="p9550103415015"><a name="p9550103415015"></a><a name="p9550103415015"></a>Opens the RTC device to obtain its handle.</p>
</td>
</tr>
<tr id="row1879052755020"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1479062716506"><a name="p1479062716506"></a><a name="p1479062716506"></a>RtcClose</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1579142745012"><a name="p1579142745012"></a><a name="p1579142745012"></a>Releases a specified handle of the RTC device.</p>
</td>
</tr>
<tr id="row34145016535"><td class="cellrowborder" rowspan="2" valign="top" width="21.902190219021904%" headers="mcps1.2.4.1.1 "><p id="p229610227124"><a name="p229610227124"></a><a name="p229610227124"></a>RTC time</p>
</td>
<td class="cellrowborder" valign="top" width="24.98249824982498%" headers="mcps1.2.4.1.2 "><p id="p19389143041518"><a name="p19389143041518"></a><a name="p19389143041518"></a>RtcReadTime</p>
</td>
<td class="cellrowborder" valign="top" width="53.11531153115312%" headers="mcps1.2.4.1.3 "><p id="p8738101941716"><a name="p8738101941716"></a><a name="p8738101941716"></a>Reads time information from the RTC driver, including the year, month, the day of the week, day, hour, minute, second, and millisecond.</p>
</td>
</tr>
<tr id="row5632152611414"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p143890309153"><a name="p143890309153"></a><a name="p143890309153"></a>RtcWriteTime</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p573815197171"><a name="p573815197171"></a><a name="p573815197171"></a>Writes time information from the RTC driver, including the year, month, the day of the week, day, hour, minute, second, and millisecond.</p>
</td>
</tr>
<tr id="row1468016592416"><td class="cellrowborder" rowspan="4" valign="top" width="21.902190219021904%" headers="mcps1.2.4.1.1 "><p id="p36817591648"><a name="p36817591648"></a><a name="p36817591648"></a>RTC alarm</p>
</td>
<td class="cellrowborder" valign="top" width="24.98249824982498%" headers="mcps1.2.4.1.2 "><p id="p968116598418"><a name="p968116598418"></a><a name="p968116598418"></a>RtcReadAlarm</p>
</td>
<td class="cellrowborder" valign="top" width="53.11531153115312%" headers="mcps1.2.4.1.3 "><p id="p768110592416"><a name="p768110592416"></a><a name="p768110592416"></a>Reads the RTC alarm time that was set last time.</p>
</td>
</tr>
<tr id="row19313155514"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p73141951155"><a name="p73141951155"></a><a name="p73141951155"></a>RtcWriteAlarm</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p15314656511"><a name="p15314656511"></a><a name="p15314656511"></a>Writes the RTC alarm time based on the alarm index.</p>
</td>
</tr>
<tr id="row138283422555"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2829142165513"><a name="p2829142165513"></a><a name="p2829142165513"></a>RtcRegisterAlarmCallback</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p118291242155518"><a name="p118291242155518"></a><a name="p118291242155518"></a>Registers <strong id="b1648234343210"><a name="b1648234343210"></a><a name="b1648234343210"></a>RtcAlarmCallback</strong> that will be invoked when an alarm is generated at the specified time.</p>
</td>
</tr>
<tr id="row13344113914568"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2344103915616"><a name="p2344103915616"></a><a name="p2344103915616"></a>RtcAlarmInterruptEnable</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p034415397565"><a name="p034415397565"></a><a name="p034415397565"></a>Enables or disables RTC alarm interrupts.</p>
</td>
</tr>
<tr id="row11801203517565"><td class="cellrowborder" rowspan="3" valign="top" width="21.902190219021904%" headers="mcps1.2.4.1.1 "><p id="p17261458942"><a name="p17261458942"></a><a name="p17261458942"></a>RTC configuration</p>
</td>
<td class="cellrowborder" valign="top" width="24.98249824982498%" headers="mcps1.2.4.1.2 "><p id="p15801153515561"><a name="p15801153515561"></a><a name="p15801153515561"></a>RtcGetFreq</p>
</td>
<td class="cellrowborder" valign="top" width="53.11531153115312%" headers="mcps1.2.4.1.3 "><p id="p980133515566"><a name="p980133515566"></a><a name="p980133515566"></a>Reads the frequency of the external crystal oscillator connected to the RTC driver.</p>
</td>
</tr>
<tr id="row111502322563"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1615073225618"><a name="p1615073225618"></a><a name="p1615073225618"></a>RtcSetFreq</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p10150832165613"><a name="p10150832165613"></a><a name="p10150832165613"></a>Sets the frequency of the external crystal oscillator connected to the RTC driver.</p>
</td>
</tr>
<tr id="row21771259145618"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1717725916562"><a name="p1717725916562"></a><a name="p1717725916562"></a>RtcReset</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p517712598569"><a name="p517712598569"></a><a name="p517712598569"></a>Resets the RTC.</p>
</td>
</tr>
<tr id="row917116425716"><td class="cellrowborder" rowspan="2" valign="top" width="21.902190219021904%" headers="mcps1.2.4.1.1 "><p id="p144765201754"><a name="p144765201754"></a><a name="p144765201754"></a>Custom register</p>
</td>
<td class="cellrowborder" valign="top" width="24.98249824982498%" headers="mcps1.2.4.1.2 "><p id="p1117110418570"><a name="p1117110418570"></a><a name="p1117110418570"></a>RtcReadReg</p>
</td>
<td class="cellrowborder" valign="top" width="53.11531153115312%" headers="mcps1.2.4.1.3 "><p id="p1517114410578"><a name="p1517114410578"></a><a name="p1517114410578"></a>Reads the configuration of a custom RTC register based on the register index.</p>
</td>
</tr>
<tr id="row46738190576"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1567331910573"><a name="p1567331910573"></a><a name="p1567331910573"></a>RtcWriteReg</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1967391913576"><a name="p1967391913576"></a><a name="p1967391913576"></a>Writes the configuration of a custom RTC register based on the register index.</p>
</td>
</tr>
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section20636145604113"></a>
### How to Use<a name="section16919828134215"></a>
During the OS startup, the HDF loads the RTC driver based on the configuration file. The RTC driver detects the RTC component and initializes the driver.
The figure below illustrates how to use the APIs.
**Figure 1** Process of using an RTC device
![](figures/using-rtc-process.png "process-of-using-an-rtc-device")
### Opening the RTC Device Handle<a name="section1131212144310"></a>
After the RTC driver is loaded, you can use the API provided by the HDF and call APIs of the RTC driver.
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>Currently, only one RTC device is supported in the OS.
DevHandle RtcOpen\(void\);
**Table 2** Description of RtcOpen
<a name="table1380712985611"></a>
<table><tbody><tr id="row580722985616"><td class="cellrowborder" valign="top" width="21.45%"><p id="p1280722911565"><a name="p1280722911565"></a><a name="p1280722911565"></a><strong id="b748651620573"><a name="b748651620573"></a><a name="b748651620573"></a>Parameter</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p5807112965618"><a name="p5807112965618"></a><a name="p5807112965618"></a><strong id="b08682171578"><a name="b08682171578"></a><a name="b08682171578"></a>Description</strong></p>
</td>
</tr>
<tr id="row17807112935611"><td class="cellrowborder" valign="top" width="21.45%"><p id="p13807132915565"><a name="p13807132915565"></a><a name="p13807132915565"></a>void</p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p15807429185612"><a name="p15807429185612"></a><a name="p15807429185612"></a>NA</p>
</td>
</tr>
<tr id="row1980782911567"><td class="cellrowborder" valign="top" width="21.45%"><p id="p0807529165613"><a name="p0807529165613"></a><a name="p0807529165613"></a><strong id="b086691895718"><a name="b086691895718"></a><a name="b086691895718"></a>Return Value</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p9808162935612"><a name="p9808162935612"></a><a name="p9808162935612"></a><strong id="b6676151975710"><a name="b6676151975710"></a><a name="b6676151975710"></a>Description</strong></p>
</td>
</tr>
<tr id="row2808192935615"><td class="cellrowborder" valign="top" width="21.45%"><p id="p380852915567"><a name="p380852915567"></a><a name="p380852915567"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p26881319114110"><a name="p26881319114110"></a><a name="p26881319114110"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row4808142945615"><td class="cellrowborder" valign="top" width="21.45%"><p id="p188084291561"><a name="p188084291561"></a><a name="p188084291561"></a>NULL</p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p780852912566"><a name="p780852912566"></a><a name="p780852912566"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
# RTC
## Overview
The real-time clock (RTC) provides precise real time for the operating system (OS) and scheduled alarming function. When the device is powered off, the RTC can accurately keep track of the system time using an auxiliary battery. The RTC regulates time with the use of a crystal oscillator.
## Available APIs
**Table 1** RTC APIs
| Category| Description|
| -------- | -------- |
| RTC handle| **RtcOpen**: opens the RTC device to obtain its handle.<br>**RtcClose**: closes the RTC device handle.|
| RTC time| **RtcReadTime**: reads the RTC time information, which includes the year, month, day, day of week, hour, minute, second, and millisecond.<br>**RtcWriteTime**: writes the RTC time, including the year, month, day, day of week, hour, minute, second, and millisecond.|
| RTC alarm| **RtcReadAlarm**: reads the RTC alarm time.<br>**RtcWriteAlarm**: writes the RTC alarm time.<br>**RtcRegisterAlarmCallback**: registers a callback to be invoked when an alarm is not generated at the specified time.<br>**RtcAlarmInterruptEnable**: enables or disables interrupts for an RTC alarm.|
| RTC configuration| **RtcGetFreq**: obtains the frequency of the external crystal oscillator connected to the RTC driver.<br>**RtcSetFreq**: sets the frequency of the external crystal oscillator connected to the RTC driver.<br>**RtcReset**: resets the RTC.|
| Custom register| **RtcReadReg**: reads a custom register.<br>**RtcWriteReg**: writes a custom register.|
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> All APIs described in this document can be called only in kernel mode.
## Usage Guidelines
### How to Use
During the OS startup, the HDF loads the RTC driver based on the configuration file. The RTC driver detects the RTC device and initializes the driver.
The figure below illustrates the general development process of an RTC device.
**Figure 1** Using the RTC APIs
![image](figures/using-RTC-process.png "Using RTC APIs")
### Opening the RTC Device Handle
After the RTC driver is loaded, the API provided by the HDF is called to invoke the APIs of the RTC driver.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> Only one RTC device is supported in the OS.
```c
DevHandle RtcOpen(void);
```
**Table 2** Description of RtcOpen
| **Parameter**| **Description**|
| -------- | -------- |
| void | NA |
| **Return Value**| **Description**|
| handle | The operation is successful.|
| NULL | The operation failed.|
```
DevHandle handle = NULL;
/* Obtain the RTC device handle. */
/* Open the RTC device handle. */
handle = RtcOpen();
if (handle == NULL) {
/* Process the error. */
/* Error handling. */
}
```
### Releasing the RTC Device Handle<a name="section10744117144314"></a>
You can call **RtcClose()** function to release the RTC device handle, thereby releasing resources of the device.
### Closing the RTC Device Handle
Call **RtcClose()** to release the resources used by the RTC device.
void RtcClose\(DevHandle handle\);
```c
void RtcClose(DevHandle handle);
```
**Table 3** Description of RtcClose
**Table 3** Description of RtcClose
| **Parameter**| **Description**|
| -------- | -------- |
| handle | RTC device handle to close.|
<a name="table37525421510"></a>
<table><tbody><tr id="row10752134216114"><td class="cellrowborder" valign="top" width="21.45%"><p id="p1075217421019"><a name="p1075217421019"></a><a name="p1075217421019"></a><strong id="b229461765710"><a name="b229461765710"></a><a name="b229461765710"></a>Parameter</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p117531421411"><a name="p117531421411"></a><a name="p117531421411"></a><strong id="b2038421875712"><a name="b2038421875712"></a><a name="b2038421875712"></a>Description</strong></p>
</td>
</tr>
<tr id="row57531442914"><td class="cellrowborder" valign="top" width="21.45%"><p id="p8753164210119"><a name="p8753164210119"></a><a name="p8753164210119"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p17533425113"><a name="p17533425113"></a><a name="p17533425113"></a>RTC device handle.</p>
</td>
</tr>
</tbody>
</table>
```
/* Release the RTC device handle. */
/* Close the RTC device handle. */
RtcClose(handle);
```
### Registering RtcAlarmCallback
After the OS is started, call the following function to register **RtcAlarmCallback**, which will be invoked when an alarm is generated at the specified time:
int32\_t RtcRegisterAlarmCallback\(DevHandle handle, enum RtcAlarmIndex alarmIndex, RtcAlarmCallback cb\);
**Table 4** Description of RtcRegisterAlarmCallback
<a name="table7603619123820"></a>
<table><thead align="left"><tr id="row1060351914386"><th class="cellrowborder" valign="top" width="21.36%" id="mcps1.2.3.1.1"><p id="p14603181917382"><a name="p14603181917382"></a><a name="p14603181917382"></a><strong id="b4295161718571"><a name="b4295161718571"></a><a name="b4295161718571"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="78.64%" id="mcps1.2.3.1.2"><p id="p36031519183819"><a name="p36031519183819"></a><a name="p36031519183819"></a><strong id="b43851218195716"><a name="b43851218195716"></a><a name="b43851218195716"></a>Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row1181618191115"><td class="cellrowborder" valign="top" width="21.36%" headers="mcps1.2.3.1.1 "><p id="p131811218131116"><a name="p131811218131116"></a><a name="p131811218131116"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%" headers="mcps1.2.3.1.2 "><p id="p6181191851111"><a name="p6181191851111"></a><a name="p6181191851111"></a>RTC device handle.</p>
</td>
</tr>
<tr id="row960361918383"><td class="cellrowborder" valign="top" width="21.36%" headers="mcps1.2.3.1.1 "><p id="p1775535165418"><a name="p1775535165418"></a><a name="p1775535165418"></a>alarmIndex</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%" headers="mcps1.2.3.1.2 "><p id="p137551851185412"><a name="p137551851185412"></a><a name="p137551851185412"></a>Alarm index.</p>
</td>
</tr>
<tr id="row1960431983813"><td class="cellrowborder" valign="top" width="21.36%" headers="mcps1.2.3.1.1 "><p id="p3604719123817"><a name="p3604719123817"></a><a name="p3604719123817"></a>cb</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%" headers="mcps1.2.3.1.2 "><p id="p1560441923818"><a name="p1560441923818"></a><a name="p1560441923818"></a>Callback that will be invoked when an alarm is generated at the specified time.</p>
</td>
</tr>
<tr id="row11410612183019"><td class="cellrowborder" valign="top" width="21.36%" headers="mcps1.2.3.1.1 "><p id="p460381915385"><a name="p460381915385"></a><a name="p460381915385"></a><strong id="b132291719185715"><a name="b132291719185715"></a><a name="b132291719185715"></a>Return Value</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.64%" headers="mcps1.2.3.1.2 "><p id="p96031619153812"><a name="p96031619153812"></a><a name="p96031619153812"></a><strong id="b5130182016576"><a name="b5130182016576"></a><a name="b5130182016576"></a>Description</strong></p>
</td>
</tr>
<tr id="row15410111273017"><td class="cellrowborder" valign="top" width="21.36%" headers="mcps1.2.3.1.1 "><p id="p133081510112813"><a name="p133081510112813"></a><a name="p133081510112813"></a>0</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%" headers="mcps1.2.3.1.2 "><p id="p530813107289"><a name="p530813107289"></a><a name="p530813107289"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row1241081213303"><td class="cellrowborder" valign="top" width="21.36%" headers="mcps1.2.3.1.1 "><p id="p1123362173010"><a name="p1123362173010"></a><a name="p1123362173010"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%" headers="mcps1.2.3.1.2 "><p id="p1723362153010"><a name="p1723362153010"></a><a name="p1723362153010"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
The following is an example of registering **RtcAlarmCallback** for processing alarm **RTC\_ALARM\_INDEX\_A**:
```
/* Register an RTC alarm callback. */
### Registering an Alarm Callback
Call **RtcRegisterAlarmCallback** to register a callback, which will be invoked when the specified alarm is not generated at the specified time.
```c
int32_t RtcRegisterAlarmCallback(DevHandle handle, enum RtcAlarmIndex alarmIndex, RtcAlarmCallback cb);
```
**Table 4** Description of RtcRegisterAlarmCallback
| **Parameter**| **Description**|
| -------- | -------- |
| handle | RTC device handle.|
| alarmIndex | Alarm index.|
| cb | Callback to be invoked when the alarm is not generated at the specified time.|
| **Return Value**| **Description**|
| 0 | The operation is successful.|
| Negative value| The operation failed.|
The following is an example of registering a callback for processing alarm RTC_ALARM_INDEX_A:
```
/* Register a callback for alarm RTC_ALARM_INDEX_A. */
int32_t RtcAlarmACallback(enum RtcAlarmIndex alarmIndex)
{
if (alarmIndex == RTC_ALARM_INDEX_A) {
/* Process alarm A. */
/* Processing of alarm A. */
} else if (alarmIndex == RTC_ALARM_INDEX_B) {
/* Process alarm B. */
/* Processing of alarm B. */
} else {
/* Process the error. */
/* Error handling. */
}
return 0;
}
int32_t ret;
/* Register RtcAlarmCallback for alarm A. */
/* Register a callback to be invoked when alarm A is not generated at the specified time. */
ret = RtcRegisterAlarmCallback(handle, RTC_ALARM_INDEX_A, RtcAlarmACallback);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
```
### Performing RTC-related Operations
- Reading RTC time
Call the **RtcReadTime()** function to read time information from the RTC driver, including the year, month, the day of the week, day, hour, minute, second, and millisecond.
int32\_t RtcReadTime\(DevHandle handle, struct RtcTime \*time\);
**Table 5** Description of RtcReadTime
<a name="table1018490043"></a>
<table><tbody><tr id="row31848013417"><td class="cellrowborder" valign="top" width="21.45%"><p id="p1415816132411"><a name="p1415816132411"></a><a name="p1415816132411"></a><strong id="b10296717125710"><a name="b10296717125710"></a><a name="b10296717125710"></a>Parameter</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p11158111316410"><a name="p11158111316410"></a><a name="p11158111316410"></a><strong id="b33873181576"><a name="b33873181576"></a><a name="b33873181576"></a>Description</strong></p>
</td>
</tr>
<tr id="row1246615200297"><td class="cellrowborder" valign="top" width="21.45%"><p id="p188871821142917"><a name="p188871821142917"></a><a name="p188871821142917"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p1788742182910"><a name="p1788742182910"></a><a name="p1788742182910"></a>RTC device handle.</p>
</td>
</tr>
<tr id="row10184701945"><td class="cellrowborder" valign="top" width="21.45%"><p id="p104891871157"><a name="p104891871157"></a><a name="p104891871157"></a>time</p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p204891671156"><a name="p204891671156"></a><a name="p204891671156"></a>Pointer to the time information read from the RTC driver. The time information includes the year, month, the day of the week, day, hour, minute, second, and millisecond.</p>
</td>
</tr>
<tr id="row17393154515328"><td class="cellrowborder" valign="top" width="21.45%"><p id="p8158313248"><a name="p8158313248"></a><a name="p8158313248"></a><strong id="b162312198575"><a name="b162312198575"></a><a name="b162312198575"></a>Return Value</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p161591413741"><a name="p161591413741"></a><a name="p161591413741"></a><strong id="b3131220165711"><a name="b3131220165711"></a><a name="b3131220165711"></a>Description</strong></p>
</td>
</tr>
<tr id="row339324593215"><td class="cellrowborder" valign="top" width="21.45%"><p id="p139599615287"><a name="p139599615287"></a><a name="p139599615287"></a>0</p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p1895911611284"><a name="p1895911611284"></a><a name="p1895911611284"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row15393184519323"><td class="cellrowborder" valign="top" width="21.45%"><p id="p13521182309"><a name="p13521182309"></a><a name="p13521182309"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.55%"><p id="p1035216186309"><a name="p1035216186309"></a><a name="p1035216186309"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
- Reading the RTC time
Call **RtcReadTime()** to obtain the RTC time, which includes the year, month, day, day of week, hour, minute, second, and millisecond.
```c
int32_t RtcReadTime(DevHandle handle, struct RtcTime *time);
```
**Table 5** Description of RtcReadTime
| **Parameter**| **Description**|
| -------- | -------- |
| handle | RTC device handle. |
| time | RTC time information, which includes the year, month, day, day of the week, hour, minute, second, and millisecond.|
| **Return Value**| **Description** |
| 0 | The operation is successful. |
| Negative value | The operation failed. |
```
int32_t ret;
struct RtcTime tm;
/* Read time information from the RTC driver. */
/* Read RTC time from the RTC driver. */
ret = RtcReadTime(handle, &tm);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
```
- Setting RTC time
Call the **RtcWriteTime()** function to set the RTC time.
int32\_t RtcWriteTime\(DevHandle handle, struct RtcTime \*time\);
**Table 6** Description of RtcWriteTime
<a name="table223910318361"></a>
<table><tbody><tr id="row924033173613"><td class="cellrowborder" valign="top" width="21.54%"><p id="p16240143143611"><a name="p16240143143611"></a><a name="p16240143143611"></a><strong id="b17297111720576"><a name="b17297111720576"></a><a name="b17297111720576"></a>Parameter</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p32401031113610"><a name="p32401031113610"></a><a name="p32401031113610"></a><strong id="b11388191825715"><a name="b11388191825715"></a><a name="b11388191825715"></a>Description</strong></p>
</td>
</tr>
<tr id="row148011248153018"><td class="cellrowborder" valign="top" width="21.54%"><p id="p189641849113018"><a name="p189641849113018"></a><a name="p189641849113018"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p20964249123013"><a name="p20964249123013"></a><a name="p20964249123013"></a>RTC device handle.</p>
</td>
</tr>
<tr id="row024043193619"><td class="cellrowborder" valign="top" width="21.54%"><p id="p157679281384"><a name="p157679281384"></a><a name="p157679281384"></a>time</p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p167675286381"><a name="p167675286381"></a><a name="p167675286381"></a>Pointer to the time information written into the RTC driver. The time information includes the year, month, the day of the week, day, hour, minute, second, and millisecond.</p>
</td>
</tr>
<tr id="row424093120369"><td class="cellrowborder" valign="top" width="21.54%"><p id="p1240143114366"><a name="p1240143114366"></a><a name="p1240143114366"></a><strong id="b1023212194579"><a name="b1023212194579"></a><a name="b1023212194579"></a>Return Value</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p18241173133619"><a name="p18241173133619"></a><a name="p18241173133619"></a><strong id="b18132142035712"><a name="b18132142035712"></a><a name="b18132142035712"></a>Description</strong></p>
</td>
</tr>
<tr id="row18241531153610"><td class="cellrowborder" valign="top" width="21.54%"><p id="p8550174182810"><a name="p8550174182810"></a><a name="p8550174182810"></a>0</p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p145503417284"><a name="p145503417284"></a><a name="p145503417284"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row024153123616"><td class="cellrowborder" valign="top" width="21.54%"><p id="p5602191619300"><a name="p5602191619300"></a><a name="p5602191619300"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p12602131643015"><a name="p12602131643015"></a><a name="p12602131643015"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>The RTC start time is 1970/01/01 Thursday 00:00:00 \(UTC\). The maximum value of **year** must be set based on the requirements specified in the product manual of the in-use component. You do not need to configure the day of the week.
- Setting the RTC time
Call **RtcWriteTime()** to set the RTC time.
```c
int32_t RtcWriteTime(DevHandle handle, struct RtcTime *time);
```
**Table 6** Description of RtcWriteTime
| **Parameter**| **Description**|
| -------- | -------- |
| handle | RTC device handle.|
| time | RTC time to set, which includes the year, month, day, day of the week, hour, minute, second, and millisecond.|
| **Return Value**| **Description**|
| 0 | The operation is successful.|
| Negative value| The operation failed.|
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The RTC start time is 1970/01/01 Thursday 00:00:00 (UTC). The maximum value of **year** must be set based on the requirements specified in the manual of the device you use. You do not need to set the day of week.
```
int32_t ret;
......@@ -370,120 +198,66 @@ tm.hour= 00;
tm.minute = 59;
tm.second = 00;
tm.millisecond = 0;
/* Write the RTC time information. */
/* Write the RTC time. */
ret = RtcWriteTime(handle, &tm);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
```
- Reading the RTC alarm time
Call the **RtcReadAlarm()** function to read the alarm time.
int32\_t RtcReadAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime \*time\);
**Table 7** Description of RtcReadAlarm
<a name="table11342203111420"></a>
<table><tbody><tr id="row133429310140"><td class="cellrowborder" valign="top" width="21.54%"><p id="p9886411201416"><a name="p9886411201416"></a><a name="p9886411201416"></a><strong id="b152971517185720"><a name="b152971517185720"></a><a name="b152971517185720"></a>Parameter</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p2886411171417"><a name="p2886411171417"></a><a name="p2886411171417"></a><strong id="b4389418135718"><a name="b4389418135718"></a><a name="b4389418135718"></a>Description</strong></p>
</td>
</tr>
<tr id="row13835647114113"><td class="cellrowborder" valign="top" width="21.54%"><p id="p1183011486412"><a name="p1183011486412"></a><a name="p1183011486412"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p1583074815413"><a name="p1583074815413"></a><a name="p1583074815413"></a>RTC device handle.</p>
</td>
</tr>
<tr id="row113439391410"><td class="cellrowborder" valign="top" width="21.54%"><p id="p132281120194318"><a name="p132281120194318"></a><a name="p132281120194318"></a>alarmIndex</p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p1022852034315"><a name="p1022852034315"></a><a name="p1022852034315"></a>Alarm index.</p>
</td>
</tr>
<tr id="row193431836147"><td class="cellrowborder" valign="top" width="21.54%"><p id="p1926195164011"><a name="p1926195164011"></a><a name="p1926195164011"></a>time</p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p112695144013"><a name="p112695144013"></a><a name="p112695144013"></a>Pointer to the RTC alarm time information. The time information includes the year, month, the day of the week, day, hour, minute, second, and millisecond.</p>
</td>
</tr>
<tr id="row43438361419"><td class="cellrowborder" valign="top" width="21.54%"><p id="p388715117143"><a name="p388715117143"></a><a name="p388715117143"></a><strong id="b14234111985715"><a name="b14234111985715"></a><a name="b14234111985715"></a>Return Value</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p088719117143"><a name="p088719117143"></a><a name="p088719117143"></a><strong id="b413222011570"><a name="b413222011570"></a><a name="b413222011570"></a>Description</strong></p>
</td>
</tr>
<tr id="row17169595467"><td class="cellrowborder" valign="top" width="21.54%"><p id="p107751111283"><a name="p107751111283"></a><a name="p107751111283"></a>0</p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p87751917289"><a name="p87751917289"></a><a name="p87751917289"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row016911915461"><td class="cellrowborder" valign="top" width="21.54%"><p id="p6833213133013"><a name="p6833213133013"></a><a name="p6833213133013"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.46%"><p id="p168341213143015"><a name="p168341213143015"></a><a name="p168341213143015"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
Call **RtcReadAlarm()** to obtain the RTC alarm time.
```c
int32_t RtcReadAlarm(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime *time);
```
**Table 7** Description of RtcReadAlarm
| **Parameter**| **Description**|
| -------- | -------- |
| handle | RTC device handle.|
| alarmIndex | Alarm index.|
| time | RTC alarm time information, which includes the year, month, day, day of the week, hour, minute, second, and millisecond.|
| **Return Value**| **Description**|
| 0 | The operation is successful.|
| Negative value | The operation failed.|
```
int32_t ret;
struct RtcTime alarmTime;
/* Read the RTC alarm time information of alarm RTC_ALARM_INDEX_A. */
/* Read the RTC alarm time of alarm RTC_ALARM_INDEX_A. */
ret = RtcReadAlarm(handle, RTC_ALARM_INDEX_A, &alarmTime);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
```
- Setting RTC alarm time
Call the **RtcWriteAlarm()** function to set the RTC alarm time based on the alarm index.
int32\_t RtcWriteAlarm\(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime \*time\);
**Table 8** Description of RtcWriteAlarm
<a name="table107922162179"></a>
<table><tbody><tr id="row14793316131710"><td class="cellrowborder" valign="top" width="21.62%"><p id="p1891718412183"><a name="p1891718412183"></a><a name="p1891718412183"></a><strong id="b029811725716"><a name="b029811725716"></a><a name="b029811725716"></a>Parameter</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p891712461814"><a name="p891712461814"></a><a name="p891712461814"></a><strong id="b1339017181576"><a name="b1339017181576"></a><a name="b1339017181576"></a>Description</strong></p>
</td>
</tr>
<tr id="row18419611133117"><td class="cellrowborder" valign="top" width="21.62%"><p id="p075881210314"><a name="p075881210314"></a><a name="p075881210314"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p975811215317"><a name="p975811215317"></a><a name="p975811215317"></a>RTC device handle.</p>
</td>
</tr>
<tr id="row11793151613176"><td class="cellrowborder" valign="top" width="21.62%"><p id="p562522145215"><a name="p562522145215"></a><a name="p562522145215"></a>alarmIndex</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p126257215217"><a name="p126257215217"></a><a name="p126257215217"></a>Alarm index.</p>
</td>
</tr>
<tr id="row37932016201720"><td class="cellrowborder" valign="top" width="21.62%"><p id="p26269212527"><a name="p26269212527"></a><a name="p26269212527"></a>time</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p462602125211"><a name="p462602125211"></a><a name="p462602125211"></a>Pointer to the RTC alarm time information. The time information includes the year, month, the day of the week, day, hour, minute, second, and millisecond.</p>
</td>
</tr>
<tr id="row586915225485"><td class="cellrowborder" valign="top" width="21.62%"><p id="p591712441810"><a name="p591712441810"></a><a name="p591712441810"></a><strong id="b1923501915574"><a name="b1923501915574"></a><a name="b1923501915574"></a>Return Value</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p1591720461810"><a name="p1591720461810"></a><a name="p1591720461810"></a><strong id="b8133152014571"><a name="b8133152014571"></a><a name="b8133152014571"></a>Description</strong></p>
</td>
</tr>
<tr id="row19869122210483"><td class="cellrowborder" valign="top" width="21.62%"><p id="p10798105812717"><a name="p10798105812717"></a><a name="p10798105812717"></a>0</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p1179817586276"><a name="p1179817586276"></a><a name="p1179817586276"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row1686918225483"><td class="cellrowborder" valign="top" width="21.62%"><p id="p16246181033012"><a name="p16246181033012"></a><a name="p16246181033012"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p3246111019309"><a name="p3246111019309"></a><a name="p3246111019309"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>The RTC start time is 1970/01/01 Thursday 00:00:00 \(UTC\). The maximum value of **year** must be set based on the requirements specified in the product manual of the in-use component. You do not need to configure the day of the week.
- Setting the RTC alarm time
Call **RtcWriteAlarm()** to set the RTC alarm time based on the alarm index.
```c
int32_t RtcWriteAlarm(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime *time);
```
**Table 8** Description of RtcWriteAlarm
| **Parameter**| **Description**|
| -------- | -------- |
| handle | RTC device handle.|
| alarmIndex | Alarm index.|
| time | RTC alarm time to set, which includes the year, month, day, day of the week, hour, minute, second, and millisecond.|
| **Return Value**| **Description**|
| 0 | The operation is successful.|
| Negative value| The operation failed.|
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The RTC start time is 1970/01/01 Thursday 00:00:00 (UTC). The maximum value of **year** must be set based on the requirements specified in the manual of the device you use. You do not need to set the day of week.
```
int32_t ret;
......@@ -500,361 +274,220 @@ alarmTime.millisecond = 0;
/* Set the alarm time of alarm RTC_ALARM_INDEX_A. */
ret = RtcWriteAlarm(handle, RTC_ALARM_INDEX_A, &alarmTime);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
```
- Enabling or disabling alarm interrupts
Before performing alarm operations, use the **RtcAlarmInterruptEnable()** function to enable alarm interrupts, so that **RtcAlarmCallback** will be called when the alarm is not generated upon a timeout.
int32\_t RtcAlarmInterruptEnable\(DevHandle handle, enum RtcAlarmIndex alarmIndex, uint8\_t enable\);
**Table 9** Description of RtcAlarmInterruptEnable
<a name="table1934615314159"></a>
<table><tbody><tr id="row5346853171519"><td class="cellrowborder" valign="top" width="21.36%"><p id="p143464533153"><a name="p143464533153"></a><a name="p143464533153"></a><strong id="b829913171576"><a name="b829913171576"></a><a name="b829913171576"></a>Parameter</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p113461853171514"><a name="p113461853171514"></a><a name="p113461853171514"></a><strong id="b9391318185714"><a name="b9391318185714"></a><a name="b9391318185714"></a>Description</strong></p>
</td>
</tr>
<tr id="row2125652144213"><td class="cellrowborder" valign="top" width="21.36%"><p id="p3150105313422"><a name="p3150105313422"></a><a name="p3150105313422"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p9151653144212"><a name="p9151653144212"></a><a name="p9151653144212"></a>RTC device handle.</p>
</td>
</tr>
<tr id="row153794518293"><td class="cellrowborder" valign="top" width="21.36%"><p id="p4259165518294"><a name="p4259165518294"></a><a name="p4259165518294"></a>alarmIndex</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p725985522917"><a name="p725985522917"></a><a name="p725985522917"></a>Alarm index.</p>
</td>
</tr>
<tr id="row19346653141518"><td class="cellrowborder" valign="top" width="21.36%"><p id="p6346253101516"><a name="p6346253101516"></a><a name="p6346253101516"></a>enable</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p234655341511"><a name="p234655341511"></a><a name="p234655341511"></a>Whether to enable RTC alarm interrupts. The value <strong id="b879021119010"><a name="b879021119010"></a><a name="b879021119010"></a>1</strong> means to enable alarm interrupts and <strong id="b779617111204"><a name="b779617111204"></a><a name="b779617111204"></a>0</strong> means to disable alarm interrupts.</p>
</td>
</tr>
<tr id="row18346953111513"><td class="cellrowborder" valign="top" width="21.36%"><p id="p53460537156"><a name="p53460537156"></a><a name="p53460537156"></a><strong id="b1023631919578"><a name="b1023631919578"></a><a name="b1023631919578"></a>Return Value</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p4346153171510"><a name="p4346153171510"></a><a name="p4346153171510"></a><strong id="b7134132075718"><a name="b7134132075718"></a><a name="b7134132075718"></a>Description</strong></p>
</td>
</tr>
<tr id="row1234685314151"><td class="cellrowborder" valign="top" width="21.36%"><p id="p8947195310279"><a name="p8947195310279"></a><a name="p8947195310279"></a>0</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p99471953152712"><a name="p99471953152712"></a><a name="p99471953152712"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row2347115321514"><td class="cellrowborder" valign="top" width="21.36%"><p id="p324855163018"><a name="p324855163018"></a><a name="p324855163018"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p7248857302"><a name="p7248857302"></a><a name="p7248857302"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
Call **RtcAlarmInterruptEnable** to enable interrupts for an RTC alarm so that the registered callback can be invoked when the alarm is not generated at the specified time.
```c
int32_t RtcAlarmInterruptEnable(DevHandle handle, enum RtcAlarmIndex alarmIndex, uint8_t enable);
```
**Table 9** Description of RtcAlarmInterruptEnable
| **Parameter**| **Description**|
| -------- | -------- |
| handle | RTC device handle.|
| alarmIndex | Alarm index.|
| enable | Whether to enable RTC alarm interrupts. The value **1** means to enable interrupts and **0** means to disable interrupts.|
| **Return Value**| **Description**|
| 0 | The operation is successful.|
| Negative value| The operation failed.|
```
int32_t ret;
/* Enable the RTC alarm interrupts. */
/* Enable interrupts for an RTC alarm. */
ret = RtcAlarmInterruptEnable(handle, RTC_ALARM_INDEX_A, 1);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
```
- Reading RTC external frequency
Call the **RtcGetFreq()** function to read the frequency of the external crystal oscillator connected to the RTC driver.
int32\_t RtcGetFreq\(DevHandle handle, uint32\_t \*freq\);
**Table 10** Description of RtcGetFreq
<a name="table125881625185"></a>
<table><tbody><tr id="row1458811241816"><td class="cellrowborder" valign="top" width="21.36%"><p id="p658820241813"><a name="p658820241813"></a><a name="p658820241813"></a><strong id="b3300217175712"><a name="b3300217175712"></a><a name="b3300217175712"></a>Parameter</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p758812261820"><a name="p758812261820"></a><a name="p758812261820"></a><strong id="b33921718195713"><a name="b33921718195713"></a><a name="b33921718195713"></a>Description</strong></p>
</td>
</tr>
<tr id="row831259124219"><td class="cellrowborder" valign="top" width="21.36%"><p id="p171541407431"><a name="p171541407431"></a><a name="p171541407431"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p715413094314"><a name="p715413094314"></a><a name="p715413094314"></a>RTC device handle.</p>
</td>
</tr>
<tr id="row1358842171820"><td class="cellrowborder" valign="top" width="21.36%"><p id="p258814210188"><a name="p258814210188"></a><a name="p258814210188"></a>freq</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p165888211810"><a name="p165888211810"></a><a name="p165888211810"></a>Pointer to the frequency to set for the external crystal oscillator, in Hz.</p>
</td>
</tr>
<tr id="row2058818281817"><td class="cellrowborder" valign="top" width="21.36%"><p id="p458872151810"><a name="p458872151810"></a><a name="p458872151810"></a><strong id="b223851915718"><a name="b223851915718"></a><a name="b223851915718"></a>Return Value</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p155880251819"><a name="p155880251819"></a><a name="p155880251819"></a><strong id="b0135182045715"><a name="b0135182045715"></a><a name="b0135182045715"></a>Description</strong></p>
</td>
</tr>
<tr id="row35883213183"><td class="cellrowborder" valign="top" width="21.36%"><p id="p8133145211272"><a name="p8133145211272"></a><a name="p8133145211272"></a>0</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p13133352202719"><a name="p13133352202719"></a><a name="p13133352202719"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row135892261811"><td class="cellrowborder" valign="top" width="21.36%"><p id="p152692538292"><a name="p152692538292"></a><a name="p152692538292"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p327015313294"><a name="p327015313294"></a><a name="p327015313294"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
- Obtaining the RTC external frequency
Call **RtcGetFreq()** to obtain the frequency of the external crystal oscillator connected to the RTC driver.
```c
int32_t RtcGetFreq(DevHandle handle, uint32_t *freq);
```
**Table 10** Description of RtcGetFreq
| **Parameter**| **Description**|
| -------- | -------- |
| handle | RTC device handle.|
| freq | Pointer to the frequency of the external crystal oscillator, in Hz.|
| **Return Value**| **Description**|
| 0 | The operation is successful.|
| Negative value| The operation failed.|
```
int32_t ret;
uint32_t freq = 0;
/* Read frequency of the external crystal oscillator connected to the RTC driver */
/* Obtain the frequency of the external crystal oscillator connected to the RTC driver. */
ret = RtcGetFreq(handle, &freq);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
```
- Setting the frequency of the external crystal oscillator connected to the RTC driver
Call the **RtcSetFreq()** function to set the frequency of the external crystal oscillator connected to the RTC driver.
int32\_t RtcSetFreq\(DevHandle handle, uint32\_t freq\);
**Table 11** Description of RtcSetFreq
<a name="table1170124316209"></a>
<table><tbody><tr id="row270119432202"><td class="cellrowborder" valign="top" width="21.36%"><p id="p127011343132010"><a name="p127011343132010"></a><a name="p127011343132010"></a><strong id="b130031711578"><a name="b130031711578"></a><a name="b130031711578"></a>Parameter</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p7701184372013"><a name="p7701184372013"></a><a name="p7701184372013"></a><strong id="b153942183570"><a name="b153942183570"></a><a name="b153942183570"></a>Description</strong></p>
</td>
</tr>
<tr id="row36067554319"><td class="cellrowborder" valign="top" width="21.36%"><p id="p881511716433"><a name="p881511716433"></a><a name="p881511716433"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p188157714432"><a name="p188157714432"></a><a name="p188157714432"></a>RTC device handle.</p>
</td>
</tr>
<tr id="row127019437204"><td class="cellrowborder" valign="top" width="21.36%"><p id="p27019438207"><a name="p27019438207"></a><a name="p27019438207"></a>freq</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p167021043182011"><a name="p167021043182011"></a><a name="p167021043182011"></a>Frequency to set for the external crystal oscillator, in Hz</p>
</td>
</tr>
<tr id="row97022434205"><td class="cellrowborder" valign="top" width="21.36%"><p id="p1770218431208"><a name="p1770218431208"></a><a name="p1770218431208"></a><strong id="b18239121916575"><a name="b18239121916575"></a><a name="b18239121916575"></a>Return Value</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p1170217432201"><a name="p1170217432201"></a><a name="p1170217432201"></a><strong id="b161361720205713"><a name="b161361720205713"></a><a name="b161361720205713"></a>Description</strong></p>
</td>
</tr>
<tr id="row1670212432206"><td class="cellrowborder" valign="top" width="21.36%"><p id="p77021543152017"><a name="p77021543152017"></a><a name="p77021543152017"></a>0</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p770214310209"><a name="p770214310209"></a><a name="p770214310209"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row10702194313201"><td class="cellrowborder" valign="top" width="21.36%"><p id="p165182216306"><a name="p165182216306"></a><a name="p165182216306"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p651815219302"><a name="p651815219302"></a><a name="p651815219302"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
- Setting the RTC external frequency
Call **RtcSetFreq()** to set the frequency of the external crystal oscillator connected to the RTC driver.
```c
int32_t RtcSetFreq(DevHandle handle, uint32_t freq);
```
**Table 11** Description of RtcSetFreq
| **Parameter**| **Description**|
| -------- | -------- |
| handle | RTC device handle.|
| freq | Pointer to the frequency to set for the external crystal oscillator, in Hz.|
| **Return Value**| **Description**|
| 0 | The operation is successful.|
| Negative value| The operation failed.|
```
int32_t ret;
uint32_t freq = 32768; /* 32768 Hz */
/* Set the frequency of the external crystal oscillator. Note that the frequency must be configured in accordance with the requirements specified in the product manual of the in-use component. */
/* Set the frequency of the external crystal oscillator based on the requirements specified in the manual of the device you use. */
ret = RtcSetFreq(handle, freq);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
```
- Resetting the RTC driver
Call the **RtcReset()** function to perform a reset on the RTC driver \(after the reset, the registers are restored to the default values\).
int32\_t RtcReset\(DevHandle handle\);
**Table 12** Description of RtcReset
<a name="table398973152517"></a>
<table><tbody><tr id="row179899311254"><td class="cellrowborder" valign="top" width="21.36%"><p id="p199899314257"><a name="p199899314257"></a><a name="p199899314257"></a><strong id="b1330101719577"><a name="b1330101719577"></a><a name="b1330101719577"></a>Parameter</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p179897315257"><a name="p179897315257"></a><a name="p179897315257"></a><strong id="b9395318115714"><a name="b9395318115714"></a><a name="b9395318115714"></a>Description</strong></p>
</td>
</tr>
<tr id="row14989113118257"><td class="cellrowborder" valign="top" width="21.36%"><p id="p129018136436"><a name="p129018136436"></a><a name="p129018136436"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p290111304310"><a name="p290111304310"></a><a name="p290111304310"></a>RTC device handle.</p>
</td>
</tr>
<tr id="row7989123111254"><td class="cellrowborder" valign="top" width="21.36%"><p id="p129894313251"><a name="p129894313251"></a><a name="p129894313251"></a><strong id="b424019198572"><a name="b424019198572"></a><a name="b424019198572"></a>Return Value</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p799013112256"><a name="p799013112256"></a><a name="p799013112256"></a><strong id="b913613204578"><a name="b913613204578"></a><a name="b913613204578"></a>Description</strong></p>
</td>
</tr>
<tr id="row9990193142513"><td class="cellrowborder" valign="top" width="21.36%"><p id="p1999043111257"><a name="p1999043111257"></a><a name="p1999043111257"></a>0</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p1799093182516"><a name="p1799093182516"></a><a name="p1799093182516"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row16990133152516"><td class="cellrowborder" valign="top" width="21.36%"><p id="p17536173573015"><a name="p17536173573015"></a><a name="p17536173573015"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.64%"><p id="p1153623503014"><a name="p1153623503014"></a><a name="p1153623503014"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
- Resetting the RTC
Call **RtcReset()** to reset the RTC. After the reset, the registers are restored to default values.
```c
int32_t RtcReset(DevHandle handle);
```
**Table 12** Description of RtcReset
| **Parameter**| **Description**|
| -------- | -------- |
| handle | RTC device handle.|
| **Return Value**| **Description**|
| 0 | The operation is successful.|
| Negative value| The operation failed.|
```
int32_t ret;
/* Reset the RTC driver. After the reset, the configuration registers are restored to the default values. */
/* Reset the RTC to restore default values of registers. */
ret = RtcReset(handle);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
```
- Reading the configuration of a custom RTC register
Call the **RtcReadReg()** function to read the configuration of a custom RTC register based on the register index \(one index corresponds to one byte of the configuration value\):
int32\_t RtcReadReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t \*value\);
**Table 13** Description of RtcReadReg
<a name="table1624674153319"></a>
<table><tbody><tr id="row92469423320"><td class="cellrowborder" valign="top" width="21.62%"><p id="p102461548331"><a name="p102461548331"></a><a name="p102461548331"></a><strong id="b73024170576"><a name="b73024170576"></a><a name="b73024170576"></a>Parameter</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p15246847331"><a name="p15246847331"></a><a name="p15246847331"></a><strong id="b1439611818570"><a name="b1439611818570"></a><a name="b1439611818570"></a>Description</strong></p>
</td>
</tr>
<tr id="row171318200434"><td class="cellrowborder" valign="top" width="21.62%"><p id="p9895321184320"><a name="p9895321184320"></a><a name="p9895321184320"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p68951214436"><a name="p68951214436"></a><a name="p68951214436"></a>RTC device handle.</p>
</td>
</tr>
<tr id="row324614143314"><td class="cellrowborder" valign="top" width="21.62%"><p id="p82466433320"><a name="p82466433320"></a><a name="p82466433320"></a>usrDefIndex</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p181671825470"><a name="p181671825470"></a><a name="p181671825470"></a>Index of the custom register</p>
</td>
</tr>
<tr id="row524716420334"><td class="cellrowborder" valign="top" width="21.62%"><p id="p8247844333"><a name="p8247844333"></a><a name="p8247844333"></a>value</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p524711413319"><a name="p524711413319"></a><a name="p524711413319"></a>Pointer to the register value</p>
</td>
</tr>
<tr id="row112471143334"><td class="cellrowborder" valign="top" width="21.62%"><p id="p1124716483312"><a name="p1124716483312"></a><a name="p1124716483312"></a><strong id="b102421419175714"><a name="b102421419175714"></a><a name="b102421419175714"></a>Return Value</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p1524716443313"><a name="p1524716443313"></a><a name="p1524716443313"></a><strong id="b11376206578"><a name="b11376206578"></a><a name="b11376206578"></a>Description</strong></p>
</td>
</tr>
<tr id="row9247194183314"><td class="cellrowborder" valign="top" width="21.62%"><p id="p62476410334"><a name="p62476410334"></a><a name="p62476410334"></a>0</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p152471433317"><a name="p152471433317"></a><a name="p152471433317"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row1424719410333"><td class="cellrowborder" valign="top" width="21.62%"><p id="p112477417335"><a name="p112477417335"></a><a name="p112477417335"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p7247547338"><a name="p7247547338"></a><a name="p7247547338"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
- Reading a custom RTC register
Call **RtcReadReg()** to read the configuration of a custom RTC register based on the register index. One index corresponds to one byte of the register value.
```c
int32_t RtcReadReg(DevHandle handle, uint8_t usrDefIndex, uint8_t *value);
```
**Table 13** Description of RtcReadReg
| **Parameter**| **Description**|
| -------- | -------- |
| handle | RTC device handle.|
| usrDefIndex | Index of the custom register.|
| value | Register value.|
| **Return Value** | **Description**|
| 0 | The operation is successful.|
| Negative value| The operation failed.|
```
int32_t ret;
uint8_t usrDefIndex = 0; /* Define index 0 for the first custom register. */
uint8_t value = 0;
/* Read the configuration of a custom RTC register based on the register index. One index corresponds to one byte of the configuration value. */
/* Read the value of custom RTC register 0. One index corresponds to one byte of the register value. */
ret = RtcReadReg(handle, usrDefIndex, &value);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
```
- Setting the configuration of a custom RTC register
Call the **RtcWriteReg()** function to configure a register based on the specified register index \(one index corresponds to one byte of the configuration value\).
int32\_t RtcWriteReg\(DevHandle handle, uint8\_t usrDefIndex, uint8\_t value\);
**Table 14** Description of RtcWriteReg
<a name="table1072216482360"></a>
<table><tbody><tr id="row187221648133611"><td class="cellrowborder" valign="top" width="21.62%"><p id="p2722184823617"><a name="p2722184823617"></a><a name="p2722184823617"></a><strong id="b530321795712"><a name="b530321795712"></a><a name="b530321795712"></a>Parameter</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p1372374810367"><a name="p1372374810367"></a><a name="p1372374810367"></a><strong id="b1339761865714"><a name="b1339761865714"></a><a name="b1339761865714"></a>Description</strong></p>
</td>
</tr>
<tr id="row1675092612435"><td class="cellrowborder" valign="top" width="21.62%"><p id="p7783927144312"><a name="p7783927144312"></a><a name="p7783927144312"></a>handle</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p197831427134310"><a name="p197831427134310"></a><a name="p197831427134310"></a>RTC device handle.</p>
</td>
</tr>
<tr id="row1723174815367"><td class="cellrowborder" valign="top" width="21.62%"><p id="p1972364814366"><a name="p1972364814366"></a><a name="p1972364814366"></a>usrDefIndex</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p18723184819365"><a name="p18723184819365"></a><a name="p18723184819365"></a>Index of the custom register</p>
</td>
</tr>
<tr id="row2723548163611"><td class="cellrowborder" valign="top" width="21.62%"><p id="p1772364893610"><a name="p1772364893610"></a><a name="p1772364893610"></a>value</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p1772324803619"><a name="p1772324803619"></a><a name="p1772324803619"></a>Register value</p>
</td>
</tr>
<tr id="row1072314482361"><td class="cellrowborder" valign="top" width="21.62%"><p id="p6723194853618"><a name="p6723194853618"></a><a name="p6723194853618"></a><strong id="b172432193575"><a name="b172432193575"></a><a name="b172432193575"></a>Return Value</strong></p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p1872314893614"><a name="p1872314893614"></a><a name="p1872314893614"></a><strong id="b131382020165711"><a name="b131382020165711"></a><a name="b131382020165711"></a>Description</strong></p>
</td>
</tr>
<tr id="row20723148173617"><td class="cellrowborder" valign="top" width="21.62%"><p id="p12723348133615"><a name="p12723348133615"></a><a name="p12723348133615"></a>0</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p472324873620"><a name="p472324873620"></a><a name="p472324873620"></a>The operation is successful.</p>
</td>
</tr>
<tr id="row127231848123615"><td class="cellrowborder" valign="top" width="21.62%"><p id="p197231148173613"><a name="p197231148173613"></a><a name="p197231148173613"></a>Negative value</p>
</td>
<td class="cellrowborder" valign="top" width="78.38000000000001%"><p id="p16723134823618"><a name="p16723134823618"></a><a name="p16723134823618"></a>The operation failed.</p>
</td>
</tr>
</tbody>
</table>
- Setting a custom RTC register
Call **RtcWriteReg()** to set a register based on the specified register index. One index corresponds to one byte of the register value.
```c
int32_t RtcWriteReg(DevHandle handle, uint8_t usrDefIndex, uint8_t value);
```
**Table 14** Description of RtcWriteReg
| **Parameter**| **Description**|
| -------- | -------- |
| handle | RTC device handle.|
| usrDefIndex | Index of the custom register.|
| value | Register value.|
| **Return Value** | **Description**|
| 0 | The operation is successful.|
| Negative value| The operation failed.|
```
int32_t ret;
uint8_t usrDefIndex = 0; /* Define index 0 for the first custom register. */
uint8_t value = 0x10;
/* Configure a register based on the specified register index. One index corresponds to one byte of the configuration value. */
/* Set a value for register 0. One index corresponds to one byte of the configuration value. */
ret = RtcWriteReg(handle, usrDefIndex, value);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
```
## Usage Example<a name="section1186111020456"></a>
This section describes the process of using RTC APIs:
## Example
The procedure is as follows:
1. During the OS startup, the HDF identifies the RTC device in the system.
1. During the OS startup, the HDF identifies the RTC component in the system.
2. The HDF initializes and creates the RTC device.
3. You can perform operations on the RTC device by calling different APIs.
4. Call the **RtcClose** function to release the device handle and device resources.
Example:
3. Call APIs to perform operations on the RTC device.
4. Close the RTC device handle to release resources.
The sample code is as follows:
```
#include "rtc_if.h"
int32_t RtcAlarmACallback(enum RtcAlarmIndex alarmIndex)
{
if (alarmIndex == RTC_ALARM_INDEX_A) {
/* Process alarm A. */
/* Processing of alarm A. */
printf("RTC Alarm A callback function\n\r");
} else if (alarmIndex == RTC_ALARM_INDEX_B) {
/* Process alarm B. */
/* Processing of alarm B. */
printf("RTC Alarm B callback function\n\r");
} else {
/* Process the error. */
/* Error handling. */
}
return 0;
}
......@@ -867,26 +500,26 @@ void RtcTestSample(void)
uint32_t freq;
DevHandle handle = NULL;
/* Obtain the RTC device handle. */
/* Open the RTC device handle. */
handle = RtcOpen();
if (handle == NULL) {
/* Process the error. */
/* Error handling. */
}
/* Register RtcAlarmCallback for alarm A. */
/* Register a callback for alarm A if it is not generated at the specified time. */
ret = RtcRegisterAlarmCallback(handle, RTC_ALARM_INDEX_A, RtcAlarmACallback);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
/* Set the RTC external crystal frequency. Note that the frequency must be configured in accordance with the requirements specified in the product manual of the in-use component. */
/* Set the frequency of the external crystal oscillator based on the requirements specified in the manual of the device you use. */
freq = 32768; /* 32768 Hz */
ret = RtcSetFreq(handle, freq);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
/* Enable the RTC alarm interrupts. */
/* Enable interrupts for RTC alarm A. */
ret = RtcAlarmInterruptEnable(handle, RTC_ALARM_INDEX_A, 1);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
/* Set the RTC time to 2020/01/01 00:00:10 .990. */
tm.year = 2020;
......@@ -896,10 +529,10 @@ void RtcTestSample(void)
tm.minute = 0;
tm.second = 10;
tm.millisecond = 990;
/* Write the RTC time information. */
/* Write the RTC time. */
ret = RtcWriteTime(handle, &tm);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
/* Set the RTC alarm time to 2020/01/01 00:00:30 .100. */
alarmTime.year = 2020;
......@@ -909,22 +542,22 @@ void RtcTestSample(void)
alarmTime.minute = 0;
alarmTime.second = 30;
alarmTime.millisecond = 100;
/* Set the alarm time information for RTC_ALARM_INDEX_A. When the specified time is reached, "RTC Alarm A callback function" is printed. */
/* Set the alarm time for RTC_ALARM_INDEX_A. When the specified time is reached, "RTC Alarm A callback function" will be printed. */
ret = RtcWriteAlarm(handle, RTC_ALARM_INDEX_A, &alarmTime);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
/* Read the RTC real time. */
/* Read the RTC time. */
ret = RtcReadTime(handle, &tm);
if (ret != 0) {
/* Process the error. */
/* Error handling. */
}
sleep(5)
printf("RTC read time:\n\r");
printf("year-month-date-weekday hour:minute:second .millisecond %04u-%02u-%02u-%u %02u:%02u:%02u .%03u",
tm.year, tm.month, tm.day, tm.weekday, tm.hour, tm.minute, tm.second, tm.millisecond);
/* Release the RTC device handle. */
/* Close the RTC device handle. */
RtcClose(handle);
}
```
# RTC<a name="EN-US_TOPIC_0000001153785954"></a>
# RTC
## Overview<a name="section509989381142407"></a>
In the Hardware Driver Foundation \(HDF\) framework, the real-time clock \(RTC\) uses the independent service mode for API adaptation. In this mode, each device independently publishes a device service to handle external access requests. After receiving an access request from an API, the device manager extracts the parameters in the request to call the internal method of the target device. In the independent service mode, the service management capabilities of the HDFDeviceManager can be directly used. However, you need to configure a device node for each device, which increases the memory usage.
## Overview
**Figure 1** Independent service mode<a name="fig6742142611299"></a>
![](figures/independent-service-mode.png "independent-service-mode-11")
The real-time clock (RTC) is a real-time clock device in the operating system. In the Hardware Driver Foundation (HDF), the RTC uses the independent service mode for API adaptation. In this mode, each device independently publishes a service to process external access requests. When receiving an access request, the HDF DeviceManager extracts parameters from the request to call the internal APIs of the target device. In the independent service mode, the HDF DeviceManager provides service management capabilities. However, you need to configure a node for each device to increase memory resources.
## Available APIs<a name="section752964871810"></a>
**Figure 1** Independent service mode
![image](figures/independent-service-mode.png "RTC independent service mode")
## Available APIs
**RtcMethod**:
RtcMethod
```
struct RtcMethod {
......@@ -27,189 +31,53 @@ struct RtcMethod {
};
```
**Table 1** Callbacks for the members in the RtcMethod structure
<a name="table12929217311"></a>
<table><thead align="left"><tr id="row293621203111"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p15932212314"><a name="p15932212314"></a><a name="p15932212314"></a>Callback</p>
</th>
<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.2"><p id="p1193421113111"><a name="p1193421113111"></a><a name="p1193421113111"></a>Input Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.3"><p id="p179312214317"><a name="p179312214317"></a><a name="p179312214317"></a>Output Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.4"><p id="p993521163113"><a name="p993521163113"></a><a name="p993521163113"></a>Return Value</p>
</th>
<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.5"><p id="p5931821123115"><a name="p5931821123115"></a><a name="p5931821123115"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1093521113114"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p14941421163112"><a name="p14941421163112"></a><a name="p14941421163112"></a>ReadTime</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p094112118314"><a name="p094112118314"></a><a name="p094112118314"></a><strong id="b1264214345404"><a name="b1264214345404"></a><a name="b1264214345404"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p19945219318"><a name="p19945219318"></a><a name="p19945219318"></a><strong id="b6902125819406"><a name="b6902125819406"></a><a name="b6902125819406"></a>time</strong>: structure pointer to the output time value.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p20941021143120"><a name="p20941021143120"></a><a name="p20941021143120"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p094132115317"><a name="p094132115317"></a><a name="p094132115317"></a>Reads the RTC time information.</p>
</td>
</tr>
<tr id="row199472183111"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p69418214318"><a name="p69418214318"></a><a name="p69418214318"></a>WriteTime</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p10306227052"><a name="p10306227052"></a><a name="p10306227052"></a><strong id="b1330617271556"><a name="b1330617271556"></a><a name="b1330617271556"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<p id="p89418214311"><a name="p89418214311"></a><a name="p89418214311"></a><strong id="b1411813377426"><a name="b1411813377426"></a><a name="b1411813377426"></a>time</strong>: structure pointer to the input time.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p3944214314"><a name="p3944214314"></a><a name="p3944214314"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p1194321113112"><a name="p1194321113112"></a><a name="p1194321113112"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p5941521123118"><a name="p5941521123118"></a><a name="p5941521123118"></a>Writes the RTC time information (from milliseconds to years).</p>
</td>
</tr>
<tr id="row4941521113111"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p19462119319"><a name="p19462119319"></a><a name="p19462119319"></a>ReadAlarm</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p1362015341251"><a name="p1362015341251"></a><a name="p1362015341251"></a><strong id="b14620934553"><a name="b14620934553"></a><a name="b14620934553"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<p id="p9951721113113"><a name="p9951721113113"></a><a name="p9951721113113"></a><strong id="b477221417458"><a name="b477221417458"></a><a name="b477221417458"></a>alarmIndex</strong>: clock alarm index, which is an enumerated value.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p1995921113112"><a name="p1995921113112"></a><a name="p1995921113112"></a><strong id="b0371144014414"><a name="b0371144014414"></a><a name="b0371144014414"></a>time</strong>: structure pointer to the output time.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p10951721133115"><a name="p10951721133115"></a><a name="p10951721133115"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p14951121193113"><a name="p14951121193113"></a><a name="p14951121193113"></a>Reads the RTC alarm time.</p>
</td>
</tr>
<tr id="row6957211313"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p129517219311"><a name="p129517219311"></a><a name="p129517219311"></a>WriteAlarm</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p136914402055"><a name="p136914402055"></a><a name="p136914402055"></a><strong id="b176918401258"><a name="b176918401258"></a><a name="b176918401258"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<p id="p11512468517"><a name="p11512468517"></a><a name="p11512468517"></a><strong id="b195114613519"><a name="b195114613519"></a><a name="b195114613519"></a>alarmIndex</strong>: clock alarm index, which is an enumerated value.</p>
<p id="p595152114315"><a name="p595152114315"></a><a name="p595152114315"></a><strong id="b1892302045019"><a name="b1892302045019"></a><a name="b1892302045019"></a>time</strong>: structure pointer to the input time.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p16951321203115"><a name="p16951321203115"></a><a name="p16951321203115"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p195321113116"><a name="p195321113116"></a><a name="p195321113116"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p1095122163116"><a name="p1095122163116"></a><a name="p1095122163116"></a>Writes the RTC alarm time.</p>
</td>
</tr>
<tr id="row1495021173112"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p795421193118"><a name="p795421193118"></a><a name="p795421193118"></a>RegisterAlarmCallback</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p7793145219520"><a name="p7793145219520"></a><a name="p7793145219520"></a><strong id="b37931529513"><a name="b37931529513"></a><a name="b37931529513"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<p id="p109352055359"><a name="p109352055359"></a><a name="p109352055359"></a><strong id="b393518551159"><a name="b393518551159"></a><a name="b393518551159"></a>alarmIndex</strong>: clock alarm index, which is an enumerated value.</p>
<p id="p1295182163112"><a name="p1295182163112"></a><a name="p1295182163112"></a><strong id="b11371112513"><a name="b11371112513"></a><a name="b11371112513"></a>cb</strong>: pointer to the callback.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p79582123118"><a name="p79582123118"></a><a name="p79582123118"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p1996122173116"><a name="p1996122173116"></a><a name="p1996122173116"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p39602133113"><a name="p39602133113"></a><a name="p39602133113"></a>Registers <strong id="b176627580513"><a name="b176627580513"></a><a name="b176627580513"></a>RtcAlarmCallback</strong> that will be invoked when an alarm is generated at the specified time.</p>
</td>
</tr>
<tr id="row6961321113110"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p129682193119"><a name="p129682193119"></a><a name="p129682193119"></a>AlarmInterruptEnable</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p796015120619"><a name="p796015120619"></a><a name="p796015120619"></a><strong id="b149601210611"><a name="b149601210611"></a><a name="b149601210611"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<p id="p174501061561"><a name="p174501061561"></a><a name="p174501061561"></a><strong id="b7450562062"><a name="b7450562062"></a><a name="b7450562062"></a>alarmIndex</strong>: clock alarm index, which is an enumerated value.</p>
<p id="p59682173112"><a name="p59682173112"></a><a name="p59682173112"></a><strong id="b6999711105518"><a name="b6999711105518"></a><a name="b6999711105518"></a>enable</strong>: specifies whether to enable the RTC alarm interrupt.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p5962021123110"><a name="p5962021123110"></a><a name="p5962021123110"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p16961621143119"><a name="p16961621143119"></a><a name="p16961621143119"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p996182112316"><a name="p996182112316"></a><a name="p996182112316"></a>Enables or disables the RTC alarm interrupt.</p>
</td>
</tr>
<tr id="row199622114317"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p09615216315"><a name="p09615216315"></a><a name="p09615216315"></a>GetFreq</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p16961021103119"><a name="p16961021103119"></a><a name="p16961021103119"></a><strong id="b17147182285715"><a name="b17147182285715"></a><a name="b17147182285715"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p09620218318"><a name="p09620218318"></a><a name="p09620218318"></a><strong id="b11413184435713"><a name="b11413184435713"></a><a name="b11413184435713"></a>freq</strong>: pointer to the output frequency, which is of the uint32_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p15961121163111"><a name="p15961121163111"></a><a name="p15961121163111"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p3968214311"><a name="p3968214311"></a><a name="p3968214311"></a>Reads the frequency of the external crystal oscillator connected to the RTC driver.</p>
</td>
</tr>
<tr id="row29692120319"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p1296421103115"><a name="p1296421103115"></a><a name="p1296421103115"></a>SetFreq</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p38121311169"><a name="p38121311169"></a><a name="p38121311169"></a><strong id="b481218117612"><a name="b481218117612"></a><a name="b481218117612"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<p id="p79792114315"><a name="p79792114315"></a><a name="p79792114315"></a><strong id="b1220510308"><a name="b1220510308"></a><a name="b1220510308"></a>freq</strong>: input frequency, which is of the uint32_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p4971021103118"><a name="p4971021103118"></a><a name="p4971021103118"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p109772117315"><a name="p109772117315"></a><a name="p109772117315"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p11971621193115"><a name="p11971621193115"></a><a name="p11971621193115"></a>Sets the frequency of the external crystal oscillator connected to the RTC driver.</p>
</td>
</tr>
<tr id="row1697112123114"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p99712117318"><a name="p99712117318"></a><a name="p99712117318"></a>Reset</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p169712123111"><a name="p169712123111"></a><a name="p169712123111"></a><strong id="b13129173210577"><a name="b13129173210577"></a><a name="b13129173210577"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p3974213312"><a name="p3974213312"></a><a name="p3974213312"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p109718210315"><a name="p109718210315"></a><a name="p109718210315"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p197112116316"><a name="p197112116316"></a><a name="p197112116316"></a>Resets the RTC.</p>
</td>
</tr>
<tr id="row3971821103115"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p2971221173111"><a name="p2971221173111"></a><a name="p2971221173111"></a>ReadReg</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p12704168619"><a name="p12704168619"></a><a name="p12704168619"></a><strong id="b1570171616616"><a name="b1570171616616"></a><a name="b1570171616616"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<p id="p18975210312"><a name="p18975210312"></a><a name="p18975210312"></a><strong id="b1020311128520"><a name="b1020311128520"></a><a name="b1020311128520"></a>usrDefIndex</strong>: structure defining the index of a custom register.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p14975211314"><a name="p14975211314"></a><a name="p14975211314"></a><strong id="b10580501973"><a name="b10580501973"></a><a name="b10580501973"></a>value</strong>: pointer to the output register value, which is of the uint8_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p15981221193114"><a name="p15981221193114"></a><a name="p15981221193114"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p1098821143115"><a name="p1098821143115"></a><a name="p1098821143115"></a>Reads the configuration of a custom RTC register based on the register index. One index corresponds to one byte of the configuration value.</p>
</td>
</tr>
<tr id="row1298102119313"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p598121153114"><a name="p598121153114"></a><a name="p598121153114"></a>WriteReg</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p1747714196613"><a name="p1747714196613"></a><a name="p1747714196613"></a><strong id="b6477519469"><a name="b6477519469"></a><a name="b6477519469"></a>host</strong>: structure pointer to the RTC controller at the core layer.</p>
<p id="p1527912317612"><a name="p1527912317612"></a><a name="p1527912317612"></a><strong id="b72791123968"><a name="b72791123968"></a><a name="b72791123968"></a>usrDefIndex</strong>: structure defining the index of a custom register.</p>
<p id="p1498172173115"><a name="p1498172173115"></a><a name="p1498172173115"></a><strong id="b68893701014"><a name="b68893701014"></a><a name="b68893701014"></a>value</strong>: input register value, which is of the uint8_t type.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p1998162193110"><a name="p1998162193110"></a><a name="p1998162193110"></a></p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p198162173118"><a name="p198162173118"></a><a name="p198162173118"></a>HDF_STATUS</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p13981421203110"><a name="p13981421203110"></a><a name="p13981421203110"></a>Configures the RTC register based on the register index. One index corresponds to one byte of the configuration value.</p>
</td>
</tr>
</tbody>
</table>
## How to Develop<a name="section1784450860142407"></a>
**Table 1** Description of the callback functions in RtcMethod
| Function| Input Parameter| Output Parameter| Return Value| Description|
| -------- | -------- | -------- | -------- | -------- |
| ReadTime | **host**: structure pointer to the RTC controller at the core layer.| **time**: structure pointer to the time read.| HDF_STATUS| Reads the RTC time.|
| WriteTime | **host**: structure pointer to the RTC controller at the core layer.<br>**time**: structure pointer to the time to write.| –| HDF_STATUS| Writes the RTC time (including the year, month, day, day of week, hour, minute, second, and millisecond).|
| ReadAlarm | **host**: structure pointer to the RTC controller at the core layer.<br>**alarmIndex**: RTC alarm index, which is an enumerated value.| **time**: structure pointer to the time read.| HDF_STATUS| Reads the RTC alarm time.|
| WriteAlarm | **host**: structure pointer to the RTC controller at the core layer.<br>**alarmIndex**: RTC alarm index, which is an enumerated value.<br>**time**: structure pointer to the time to write.| –| HDF_STATUS| Writes the RTC alarm time.|
| RegisterAlarmCallback | **host**: structure pointer to the RTC controller at the core layer.<br>**alarmIndex**: RTC alarm index, which is an enumerated value.<br>**cb**: pointer to the callback to register.| –| HDF_STATUS| Registers a callback to be invoked when an alarm is not generated at the specified time.|
| AlarmInterruptEnable | **host**: structure pointer to the RTC controller at the core layer.<br>**alarmIndex**: RTC alarm index, which is an enumerated value.<br>**enable**: whether to enable interrupts for an RTC alarm. | –| HDF_STATUS| Enables or disables interrupts for an RTC alarm.|
| GetFreq | **host**: structure pointer to the RTC controller at the core layer.| **freq**: pointer to the frequency obtained, which is of the uint32_t type.| HDF_STATUS| Obtains the frequency of the external crystal oscillator connected to the RTC driver.|
| SetFreq | **host**: structure pointer to the RTC controller at the core layer.<br>**freq**: frequency to set, which is of the uint32_t type.| –| HDF_STATUS| Sets the frequency of the external crystal oscillator connected to the RTC driver.|
| Reset | **host**: structure pointer to the RTC controller at the core layer.| –| HDF_STATUS| Resets the RTC.|
| ReadReg | **host**: structure pointer to the RTC controller at the core layer.<br>**usrDefIndex**: index of a custom register.| **value**: pointer to the register value obtained, which is of the uint8_t type.| HDF_STATUS| Reads a custom RTC register. A register index corresponds to one byte of the register value.|
| WriteReg | **host**: structure pointer to the RTC controller at the core layer.<br>**usrDefIndex**: index of a custom register.<br>**value**: register value to write, which is of the uint8_t type.| –| HDF_STATUS| Writes a custom RTC register. A register index corresponds to one byte of the register value.|
## How to Develop
The RTC module adaptation involves the following steps:
1. Instantiate the driver entry.
- Instantiate the **HdfDriverEntry** structure.
- Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF.
- Call **HDF_INIT** to register the **HdfDriverEntry** instance with the HDF.
2. Configure attribute files.
- Add the **deviceNode** information to the **device\_info.hcs** file.
- \(Optional\) Add the **rtc\_config.hcs** file.
- Add the **deviceNode** information to the **device_info.hcs** file.
- (Optional) Add the **rtc_config.hcs** file.
3. Instantiate the RTC controller object.
- Initialize **RtcHost**.
- Instantiate **RtcMethod** in the **RtcHost** object.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> For details about the functions in **RtcMethod**, see [Available APIs](#available-apis).
For details, see [Available APIs](#available-apis).
4. \(Optional\) Debug the driver.
For new drivers, verify the basic functions, such as the RTC control status and response to interrupts.
4. Debug the driver.
(Optional) For new drivers, verify the basic functions, such as the RTC status control and response to interrupts.
## Development Example<a name="section1594883301142407"></a>
## Development Example
The following uses **rtc\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions.
The following uses **rtc_hi35xx.c** as an example to present the information required for implementing device functions.
1. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
1. Instantiate the driver entry.<br/>The driver entry must be a global variable of the **HdfDriverEntry** type (defined in **hdf_device_desc.h**), and the value of **moduleName** must be the same as that in **device_info.hcs**. In the HDF framework, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke.
Generally, the HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, the HDF calls **Release** to release driver resources and exit.
Generally, HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, HDF calls **Release** to release driver resources and exit.
- RTC driver entry reference
RTC driver entry example:
```
struct HdfDriverEntry g_rtcDriverEntry = {
......@@ -217,17 +85,19 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents that
.Bind = HiRtcBind, // See the Bind function.
.Init = HiRtcInit, // See the Init function.
.Release = HiRtcRelease, //See the Release function.
.moduleName = "HDF_PLATFORM_RTC", // (Mandatory) This parameter must be the same as that in the .hcs file.
.moduleName = "HDF_PLATFORM_RTC", // (Mandatory) The value must be the same as that in the .hcs file.
};
// Call HDF_INIT to register the driver entry with the HDF.
HDF_INIT(g_rtcDriverEntry);
```
2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **rtc\_config.hcs** file. The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the default values or value ranges of the **RtcHost** members at the core layer.
2. Add the **deviceNode** information to the **device_info.hcs** file and configure the device attributes in the **rtc_config.hcs** file.
The **deviceNode** information is related to registration of the driver entry. The device attribute values are closely related to the default values or value ranges of the **RtcHost** members at the core layer.
In this example, there is only one RTC controller. If there are multiple RTC controllers, you need to add the **deviceNode** information to the **device_info** file and add the corresponding device attributes to the **rtc_config** file for each controller.
In this example, there is only one RTC controller. If there are multiple RTC controllers, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **rtc\_config** file.
- **device_info.hcs** configuration example
- **device\_info.hcs** configuration reference
```
root {
......@@ -235,11 +105,11 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents that
platform :: host {
device_rtc :: device {
device0 :: deviceNode {
policy = 1; // 2: The driver publishes user-mode services. 1: The driver publishes kernel-mode services. 0: No service needs to be published.
policy = 1; // The driver publishes services for kernel-mode processes only.
priority = 30; // A smaller value indicates a higher priority.
permission = 0644; // Permission for the driver to create a device node
moduleName = "HDF_PLATFORM_RTC"; // (Mandatory) Driver name, which must be the same as the moduleName in the driver entry.
serviceName = "HDF_PLATFORM_RTC"; // (Mandatory) Unique name of the service published by the driver
moduleName = "HDF_PLATFORM_RTC"; // (Mandatory) Driver name, which must be the same as moduleName in the driver entry.
serviceName = "HDF_PLATFORM_RTC"; // (Mandatory) Unique name of the service published by the driver.
deviceMatchAttr = "hisilicon_hi35xx_rtc";// The value must be the same as that of match_attr in the .hcs file.
}
}
......@@ -248,7 +118,8 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents that
}
```
- **rtc\_config.hcs** configuration reference
- **rtc_config.hcs** configuration example
```
root {
......@@ -256,9 +127,9 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents that
rtc_config {
controller_0x12080000 {
match_attr = "hisilicon_hi35xx_rtc";// (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs.
rtcSpiBaseAddr = 0x12080000; // Used for address mapping
regAddrLength = 0x100; // Used for address mapping
irq = 37; // Interruption number
rtcSpiBaseAddr = 0x12080000; // Used for address mapping.
regAddrLength = 0x100; // Used for address mapping.
irq = 37; // Interrupt number.
supportAnaCtrl = false;
supportLock = false;
anaCtrlAddr = 0xff;
......@@ -272,27 +143,28 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents that
}
```
3. Initialize the **RtcHost** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **RtcMethod** \(used to call underlying functions of the driver\) in **RtcHost**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\).
- Custom structure reference
3. Initialize the **RtcHost** object at the core layer, including defining a custom structure (to pass parameters and data) and implementing the **HdfDriverEntry** member functions (**Bind**, **Init** and **Release**) to instantiate **RtcMethod** in **RtcHost** (so that the underlying driver functions can be called).
- Defining a custom structure
To the driver, the custom structure holds parameters and data. The **DeviceResourceIface** method provided by the HDF reads the values in the **rtc_config.hcs** file to initialize the members in the custom structure.
To the driver, the custom structure carries parameters and data. The values in the **rtc\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**.
```
struct RtcConfigInfo {
uint32_t spiBaseAddr; // Used for address mapping
volatile void *remapBaseAddr; // Used for address mapping
uint16_t regAddrLength; // Used for address mapping
uint8_t supportAnaCtrl; // Indicates whether ANACTRL is supported.
uint8_t supportLock; // Indicates whether lock is supported.
uint8_t irq; // Interrupt number
uint8_t alarmIndex; // Clock alarm index
uint8_t anaCtrlAddr; // ANACTRL address
struct RtcLockAddr lockAddr; // Lock address
RtcAlarmCallback cb; // Callback
struct OsalMutex mutex; // Mutex
uint32_t spiBaseAddr; // Used for address mapping.
volatile void *remapBaseAddr; // Used for address mapping.
uint16_t regAddrLength; // Used for address mapping.
uint8_t supportAnaCtrl; // Whether ANACTRL is supported.
uint8_t supportLock; // Whether lock is supported.
uint8_t irq; // Interrupt number.
uint8_t alarmIndex; // RTC alarm index.
uint8_t anaCtrlAddr; // ANACTRL address.
struct RtcLockAddr lockAddr; // Lock address.
RtcAlarmCallback cb; // Callback.
struct OsalMutex mutex; // Mutex.
};
// RtcHost is the controller structure at the core layer. Its members are assigned with values by using the Init function.
// RtcHost is the controller structure at the core layer. The Init function assigns values to the members of RtcHost.
struct RtcHost {
struct IDeviceIoService service;
struct HdfDeviceObject *device;
......@@ -300,8 +172,8 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents that
void *data;
};
```
- Instantiating **RtcMethod** in **RtcHost** (other members are initialized by **Init**)
- Instantiate the callback function structure **RtcMethod** in **RtcHost**. Other members are initialized by using the **Init** function.
```
// Example in rtc_hi35xx.c: instantiate the hook.
......@@ -322,87 +194,58 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents that
- Bind function
Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return values:
HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **//drivers/framework/include/utils/hdf\_base.h** file.\)
**Table 2** Input parameters and return values of the Bind function
<a name="table14285177465"></a>
<table><thead align="left"><tr id="row6280177461"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p528181764613"><a name="p528181764613"></a><a name="p528181764613"></a>Status (Value)</p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p192891754615"><a name="p192891754615"></a><a name="p192891754615"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1328191713465"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p02812173467"><a name="p02812173467"></a><a name="p02812173467"></a>HDF_ERR_INVALID_OBJECT</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p142861714610"><a name="p142861714610"></a><a name="p142861714610"></a>Invalid controller object</p>
</td>
</tr>
<tr id="row19288170464"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p16282017184619"><a name="p16282017184619"></a><a name="p16282017184619"></a>HDF_ERR_MALLOC_FAIL</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p02841754611"><a name="p02841754611"></a><a name="p02841754611"></a>Failed to allocate memory</p>
</td>
</tr>
<tr id="row229131734619"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p429171784617"><a name="p429171784617"></a><a name="p429171784617"></a>HDF_ERR_INVALID_PARAM</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1229151764617"><a name="p1229151764617"></a><a name="p1229151764617"></a>Invalid parameter</p>
</td>
</tr>
<tr id="row6291017154612"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p15294179461"><a name="p15294179461"></a><a name="p15294179461"></a>HDF_ERR_IO</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p329517154617"><a name="p329517154617"></a><a name="p329517154617"></a>I/O error</p>
</td>
</tr>
<tr id="row9298171469"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p13297172461"><a name="p13297172461"></a><a name="p13297172461"></a>HDF_SUCCESS</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p11299171460"><a name="p11299171460"></a><a name="p11299171460"></a>Initialization successful</p>
</td>
</tr>
<tr id="row122911175467"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p32931744612"><a name="p32931744612"></a><a name="p32931744612"></a>HDF_FAILURE</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p102911724610"><a name="p102911724610"></a><a name="p102911724610"></a>Initialization failed</p>
</td>
</tr>
</tbody>
</table>
Input parameter:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information.
Return value:
HDF_STATUS<br/>The table below describes some status. For more information, see **HDF_STATUS** in the **/drivers/framework/include/utils/hdf_base.h** file.
**Table 2** HDF_STATUS
| Status| Description|
| -------- | -------- |
| HDF_ERR_INVALID_OBJECT | Invalid controller object.|
| HDF_ERR_MALLOC_FAIL | Failed to allocate memory.|
| HDF_ERR_INVALID_PARAM | Invalid parameter.|
| HDF_ERR_IO | I/O error.|
| HDF_SUCCESS | Initialization successful.|
| HDF_FAILURE | Initialization failed.|
Function description:
Associates the **HdfDeviceObject** object and **RtcHost**.
Binds the **HdfDeviceObject** object and **RtcHost**.
```
static int32_t HiRtcBind(struct HdfDeviceObject *device)
{
struct RtcHost *host = NULL;
host = RtcHostCreate(device); // Apply for memory and connect to the device: host->device = device;
// Enable conversion between HdfDeviceObject and RtcHost.
host = RtcHostCreate(device); // Allocate memory and attach the device host and the device.
// Prerequisite for conversion between HdfDeviceObject and RtcHost.
...
device->service = &host->service; // Enable conversion between HdfDeviceObject and RtcHost.
// This setting enables the host to be globally used by calling RtcHostFromDevice.
device->service = &host->service; // Prerequisite for conversion between HdfDeviceObject and RtcHost.
// It allows the global use of host by calling RtcHostFromDevice.
return HDF_SUCCESS;
}
```
- Init function
- **Init** function
Input parameters:
Input parameter:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information.
Return values:
Return value:
HDF\_STATUS
HDF_STATUS
Function description:
Initializes the custom structure object and **RtcHost**.
```
static int32_t HiRtcInit(struct HdfDeviceObject *device)
{
......@@ -412,38 +255,38 @@ The following uses **rtc\_hi35xx.c** as an example to present the contents that
host = RtcHostFromDevice(device);// A forced conversion from HdfDeviceObject to RtcHost is involved.
rtcInfo = OsalMemCalloc(sizeof(*rtcInfo));
...
// HiRtcConfigData reads attributes from the device configuration tree and fills in supportAnaCtrl, supportLock, spiBaseAddr, regAddrLength, and irq in rtcInfo.
// HiRtcConfigData reads attributes from the device configuration tree and fills the values in supportAnaCtrl, supportLock, spiBaseAddr, regAddrLength, and irq in rtcInfo.
// Provide parameters for HiRtcSwInit and HiRtcSwInit, and perform operations such as releasing memory when the function internal processing fails.
if (HiRtcConfigData(rtcInfo, device->property) != 0) {
...
}
if (HiRtcSwInit(rtcInfo)! = 0) {// Related to address mapping and interrupt registration
if (HiRtcSwInit(rtcInfo)! = 0) {// Address mapping and interrupt registration.
...
}
if (HiRtcHwInit(rtcInfo)! = 0) {// Initialize ANACTRL and lockAddr.
...
}
host->method = &g_method; // Connect to the UARTHostMethod instance.
host->data = rtcInfo; // Enable conversion between RtcConfigInfo and RtcHost.
host->method = &g_method; // Attach the RtcMethod instance.
host->data = rtcInfo; // Prerequisites for conversion between RtcConfigInfo and RtcHost.
HDF_LOGI("Hdf dev service:%s init success!", HdfDeviceGetServiceName(device));
return HDF_SUCCESS;
}
```
- **Release** function
- Release function
Input parameter:
Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information.
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information.
Return value:
Return values:
No value is returned.
Function description:
**Function description**:
Releases the memory and deletes the controller. This function assigns values to the **Release** function in the driver entry structure. If the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** or **Bind** function has the corresponding value assignment operations.
Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** or **Bind** function has the corresponding value assignment operations.
```
static void HiRtcRelease(struct HdfDeviceObject *device)
......
......@@ -31,7 +31,7 @@ For details about the HiSysEvent class, see the API reference.
| static const std::string AAFWK | Atomic ability subsystem|
| static const std::string APPEXECFWK | User program framework subsystem|
| static const std::string ACCOUNT | Account subsystem|
| static const std::string ACE | JS application framework|
| static const std::string ARKUI | ARKUI subsystem|
| static const std::string AI | AI subsystem|
| static const std::string BARRIER_FREE | Accessibility subsystem|
| static const std::string BIOMETRICS | Biometric recognition subsystem|
......
......@@ -47,13 +47,13 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin**
```
# hisysevent -r -t "TAG" -c PREFIX
{"domain_":"ACE","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""}
{"domain_":"ARKUI","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""}
# hisysevent -r -t "TA\w{0,1}" -c REGULAR
{"domain_":"WINDOWMANAGER","name_":"NO_FOCUS_WINDOW","type_":1,"time_":1501940269802,"tz_":"+0000","tag_":"TAG","pid_":1428,"tid_":1433,"uid_":10001,"level_":"CRITICAL","info_":""}
{"domain_":"ACE","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""}
{"domain_":"ARKUI","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""}
# hisysevent -r -t "TA\w+" -c REGULAR
{"domain_":"WINDOWMANAGER","name_":"NO_FOCUS_WINDOW","type_":1,"time_":1501940269802,"tz_":"+0000","tag_":"TAG","pid_":1428,"tid_":1433,"uid_":10001,"level_":"CRITICAL","info_":""}
{"domain_":"ACE","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""}
{"domain_":"ARKUI","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""}
```
- Command for subscribing to real-time system events by event domain and event name:
......
......@@ -36,7 +36,7 @@ Each application can subscribe to common events as required. After your applicat
## How to Use
For details, see *CommonEvent Development Guidelines*.
For details, see [Common Event Development](../application-dev/notification/common-event.md).
## Repositories Involved
......
# OpenHarmony 3.1.1 Release
## Version Description
OpenHarmony 3.1.1 Release provides the following enhancements over OpenHarmony 3.1 Release:
**Enhanced basic capabilities for the standard system**
System service management is enhanced to support group verification. Power management now supports brightness adjustment and battery information query. The Misc services subsystem supports HTTP file download APIs.
The location service subsystem now implements basic positioning APIs. The window manager subsystem supports setting of window properties. The multimedia subsystem provides APIs related to audio focus and audio decoding.
Network management supports Ethernet connections. WebSocket JS APIs are added, which are compatible with the **\@system.fetch** and **\@system.network** APIs.
**Enhanced distributed capabilities for the standard system**
Distributed data management is now compatible with the **\@system.storage** APIs.
**Enhanced application framework capabilities for the standard system**
Bundle management supports application-specific installation status query. The common event and notification subsystem provides APIs for sending and canceling notifications.
The Feature Ability (FA) model supports ability-level screen orientation query and setting, lock screen display, and screen-on during ability startup. DFX features, such as Application Not Response (ANR) and suspension detection for an application's main thread, are added. More basic capabilities are added for FA widgets.
**Enhanced application capabilities for the standard system**
The Contacts application allows third-party applications to invoke the system call capability, so end users can use the basic communication capabilities of devices.
## Version Mapping
**Table 1** Version mapping of software and tools
| Software/Tool| Version| Remarks|
| -------- | -------- | -------- |
| OpenHarmony | 3.1.1&nbsp;Release | NA |
| SDK | Ohos_sdk_full&nbsp;3.1.6.5 (API&nbsp;Version&nbsp;8&nbsp;Release) | NA |
| (Optional) HUAWEI DevEco Studio| 3.0&nbsp;Beta3&nbsp;for&nbsp;OpenHarmony | Recommended for developing OpenHarmony applications|
| (Optional) HUAWEI DevEco Device Tool| 3.0&nbsp;Release | Recommended for developing OpenHarmony devices|
## Source Code Acquisition
### Prerequisites
1. Register your account with Gitee.
2. Register an SSH public key for access to Gitee.
3. Install the [git client](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading), and configure user information.
```
git config --global user.name "yourname"
git config --global user.email "your-email-address"
git config --global credential.helper store
```
4. Run the following commands to install the **repo** tool:
```
curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo # If you do not have the permission, download the tool to another directory and configure it as an environment variable by running the chmod a+x /usr/local/bin/repo command.
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
```
### Acquiring Source Code Using the repo Tool
**Method 1 (recommended)**
Use the **repo** tool to download the source code over SSH. (You must have an SSH public key for access to Gitee.)
```
repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.1.1-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
**Method 2**
Use the **repo** tool to download the source code over HTTPS.
```
repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony-v3.1.1-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
### Acquiring Source Code from Mirrors
**Table 2** Mirrors for acquiring source code
| Source Code | Version| Mirror | SHA-256 Checksum |
| --------------------------------------- | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| Full code base (for mini, small, and standard systems) | 3.1 Release | [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/code-v3.1.1-Release.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/code-v3.1.1-Release.tar.gz.sha256)|
| Hi3516 standard system solution (binary) | 3.1 Release | [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_hi3516.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_hi3516.tar.gz.sha256)|
| RK3568 standard system solution (binary) | 3.1 Release | [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz.sha256)|
| Hi3861 mini system solution (binary) | 3.1 Release | [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/hispark_pegasus.tar.gz.sha256) |
| Hi3516 mini system solution - LiteOS (binary)| 3.1 Release | [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/hispark_taurus.tar.gz.sha256) |
| Hi3516 mini system solution - Linux (binary) | 3.1 Release | [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/hispark_taurus_linux.tar.gz.sha256) |
| Standard system SDK package (macOS) | 3.1 Release | [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-mac-full.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-mac-full.tar.gz.sha256)|
| Standard system SDK package (Windows/Linux) | 3.1 Release | [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-full.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-full.tar.gz.sha256)|
## What's New
This version has the following updates to OpenHarmony 3.1 Release.
### Feature Updates
**Table 3** New and enhanced features
| Subsystem| Standard System| Mini and Small Systems|
| -------- | -------- | -------- |
| System service management| Added group verification.<br>The following requirement is involved:<br>I52G5Q Adding group verification| NA |
| Power management| Added the APIs for brightness adjustment and battery information query.<br>The following requirements are involved:<br>I526UP Supporting the **\@system.brightness** APIs<br>I526UP Supporting the **\@system.battery** APIs| NA |
| Bundle management| Added the APIs for querying whether a specified application is installed.<br>The following requirements are involved:<br>I56EWD Test framework configuration<br>I55RZJ Querying whether a specified application is installed| NA |
| Location service| Added compatibility with basic positioning APIs.<br>The following requirement is involved:<br>I53WFP Basic positioning capabilities and system APIs| NA |
| Ability| Added the following features to the FA model: ability-level screen orientation query and setting, lock screen display, and screen-on upon startup.<br>The following requirements are involved:<br>I56EH7 Querying and setting the landscape/portrait mode for an ability in the FA model<br>I50D5Y Lock screen display for an ability in the FA model<br>I56EH7 Screen-on during ability startup in the FA model<br>I55WB0 Carrying images in widget data<br>I55WB0 FA widget capability supplement - formManager reconstruction<br>I55WB0 FA widget capability supplement - widget status query<br>I55WB0 FA widget capability supplement - deleting invalid widgets<br>I55WB0 FA widget capability supplement - separate setting of the visibility and update status of widgets<br>I50D8H Interception of uncatched exceptions<br>I50D91 ANR processing| NA |
| Media| Added APIs related to audio focus and audio decoding.<br>The following requirements are involved:<br>I56REO Supplementing audio focus/device APIs<br>I522W0 AMR audio encoding| NA |
| Window manager| Added support for setting window properties.<br>The following requirement is involved:<br>I56EH7 Window property setting| NA |
| Network management| Added support for WebSocket and fetch APIs and Ethernet connections.<br>The following requirements are involved:<br>I53CKH Supporting the **\@system.fetch** APIs<br>I53CJX Supporting the **\@system.network** APIs<br>I53CKT WebSocket support<br>I580PC Ethernet connections| NA |
| Misc services| Added compatibility with HTTP file download APIs.<br>The following requirement is involved:<br>I56Q4X Supporting file download APIs| NA |
| Common event and notification| Added the APIs for sending and canceling notifications.<br>The following requirements are involved:<br>I50EEW APIs for sending and canceling notifications| NA |
| Distributed data management| Added compatibility with the **\@system.storage** APIs.<br>The following requirement is involved:<br>I56RF3 Supporting the **\@system.storage** APIs| NA |
| Startup| Added compatibility with the **\@system.device** APIs.<br>The following requirement is involved:<br>I56GBS Supporting the **\@system.device** APIs| NA |
| System applications| The Contacts application allows third-party applications to invoke the system call capability.<br>The following requirements are involved:<br>I58ZQ4 The Contacts application allows third-party applications to invoke the system call capability.| NA |
### API Updates
This version does not involve API updates.
### Chip and Development Board Adaptation
For details about the adaptation status, see [SIG-Devboard](https://gitee.com/openharmony/community/blob/master/sig/sig-devboard/sig_devboard.md).
## Resolved Issues
**Table 4** Resolved issues
| Issue No. | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [I4UUFR](https://gitee.com/openharmony/third_party_e2fsprogs/issues/I4UUFR) | Local image compilation and build may fail for the Hi3516 development board. |
| [I4WDD3](https://gitee.com/openharmony/multimedia_camera_standard/issues/I4WDD3) | [RK3568] A recorded video cannot be viewed. |
| [I50EBB](https://gitee.com/openharmony/docs/issues/I50EBB) | [Hi3516 burning] Images of the Hi3516 development board on a standard-system device cannot be burnt by using DevEco Device Tool. |
## Known Issues
**Table 5** Known issues
| Issue No. | Description | Impact | To Be Resolved By|
| ------------------------------------------------------------ | ---------------------------------------------------------- | ------------------------------------------------- | ------------ |
| [I4Z3G9](https://gitee.com/openharmony/graphic_graphic_2d/issues/I4Z3G9) | [RK3568] Screen flickering occurs when the secondary window is opened in the immersive primary window.| Developer experience is affected. | 2022-06-15 |
| [I58GFY](https://gitee.com/openharmony/communication_wifi/issues/I58GFY) | [RK3568] On the 2.4 GHz and 5 GHz frequency bands, connections fail in WPA+TKIP/AES encryption mode. | The TP-Link AX50 router cannot connect to the Wi-Fi network. | 2022-06-30 |
| [I59P32](https://gitee.com/openharmony/device_manager/issues/I59P32) | [RK3568] After the trust period of a device expires, PIN authentication cannot be performed. | This issue occurs when the timer waiting for the PIN code input times out. It can be resolved by restarting the device.| 2022-06-15 |
# OpenHarmony 3.2 Beta1
## Version Description
OpenHarmony 3.2 Beta1 provides the following enhancements over OpenHarmony 3.1 Release:
**Enhanced basic capabilities for the mini system**
The inter-process communication (IPC) mechanism is normalized for LiteOS and Linux running on the mini system. Now both local and distributed IPC capabilities are available for distributed services and applications.
**Enhanced basic capabilities for the standard system**
ARM64 build is supported.
The graphics system supports secure screen capturing and screen recording. It also supports application window display over other applications.
The window manager subsystem supports quick switching to the home screen and restoration of application windows. It also supports screen wakeup, screen always-on, and screen brightness adjustment from the window, as well as security layer.
Ark VMs support multi-instance debugging, conditional breakpoints, and watch expressions.
The multimodal input subsystem supports hot swap listening of the remote control, mouse, and keyboard.
The security subsystem supports mutual authentication between OpenHarmony devices using the same account.
**Enhanced distributed capabilities for the standard system**
System service management is enhanced to support group verification.
**Enhanced application framework capabilities for the standard system**
ArkUI allows an ability to be displayed in other applications as a component. The **\<Column>** and **\<SideBarContainer>** components are enhanced to support automatic hiding.
Bundle management supports installation, uninstall, and query of sandbox applications. The unpacking tool supports the stage model.
The stage model supports the Worker mechanism. DFX features, such as Application Not Response (ANR) and suspension detection of an application's main thread, are added.
**Enhanced application capabilities for the standard system**
The Gallery application supports basic dynamic effects, image editing and saving, and OEM customization.
**Application development samples for the standard system**
Multiple sample apps, including GPU drawing, minesweeper game, and 2048 game, are provided to help developers quickly use the basic capabilities of OpenHarmony.
## Version Mapping
**Table 1** Version mapping of software and tools
| Software/Tool| Version| Remarks|
| -------- | -------- | -------- |
| OpenHarmony | 3.2&nbsp;Beta1 | NA |
| SDK | Ohos_sdk_full&nbsp;3.2.2.5 (API&nbsp;Version&nbsp;9 Beta1) | NA |
| (Optional) HUAWEI DevEco Studio| 3.2&nbsp;Beta1&nbsp;for&nbsp;OpenHarmony | Recommended for developing OpenHarmony applications|
| (Optional) HUAWEI DevEco Device Tool| 3.2&nbsp;Beta1 | Recommended for developing OpenHarmony devices|
## Source Code Acquisition
### Prerequisites
1. Register your account with Gitee.
2. Register an SSH public key for access to Gitee.
3. Install the [git client](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading), and configure user information.
```
git config --global user.name "yourname"
git config --global user.email "your-email-address"
git config --global credential.helper store
```
4. Run the following commands to install the **repo** tool:
```
curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo # If you do not have the permission, download the tool to another directory and configure it as an environment variable by running the chmod a+x /usr/local/bin/repo command.
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
```
### Acquiring Source Code Using the repo Tool
**Method 1 (recommended)**
Use the **repo** tool to download the source code over SSH. (You must have an SSH public key for access to Gitee.)
- Obtain the source code from the version branch. You can obtain the latest source code of the version branch, which includes the code that has been incorporated into the branch up until the time you run the following commands:
```
repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.2-Beta1 --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
- Obtain the source code from the version tag, which is the same as that released with the version.
```
repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.2-Beta1 --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
**Method 2**
Use the **repo** tool to download the source code over HTTPS.
- Obtain the source code from the version branch. You can obtain the latest source code of the version branch, which includes the code that has been incorporated into the branch up until the time you run the following commands:
```
repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony-3.2-Beta1 --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
- Obtain the source code from the version tag, which is the same as that released with the version.
```
repo init -u https://gitee.com/openharmony/manifest -b refs/tags/OpenHarmony-v3.2-Beta1 --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
### Acquiring Source Code from Mirrors
**Table 2** Mirrors for acquiring source code
| Source Code | Version| Mirror | SHA-256 Checksum |
| --------------------------------------- | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| Full code base (for mini, small, and standard systems) | 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/code-v3.2-Beta1.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/code-v3.2-Beta1.tar.gz.sha256)|
| RK3568 standard system solution (binary) | 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/standard_rk3568.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz.sha256)|
| Hi3861 mini system solution (binary) | 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_pegasus.tar.gz.sha256) |
| Hi3516 mini system solution - LiteOS (binary)| 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus.tar.gz.sha256) |
| Hi3516 mini system solution - Linux (binary) | 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus_linux.tar.gz.sha256) |
| Standard system SDK package (macOS) | 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/ohos-sdk-mac.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/ohos-sdk-mac.tar.gz.sha256)|
| Standard system SDK package (Windows/Linux) | 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/ohos-sdk.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/ohos-sdk.tar.gz.sha256)|
## What's New
This version has the following updates to OpenHarmony 3.1 Release.
### Feature Updates
**Table 3** New and enhanced features
| Subsystem| Standard System| Mini and Small Systems|
| -------- | -------- | -------- |
| Common| ARM64 build is supported.| The same set of IPC APIs is provided for the mini, small, and standard systems.|
| Resource scheduling| Statistics on widget usage can be collected.<br>The following requirements are involved:<br>I531ST Deleting the usage records of a widget once it is uninstalled<br>I531SU Querying and obtaining widget usage records<br>I531SV Recording the widget usage count and usage duration| NA |
| Multimodal input| Listening for hot swap events of the remote control, mouse, and keyboard is supported<br>The following requirements are involved:<br>I530U7 Third-party JSON version upgrade<br>I530UH Startup optimization<br>I530UU Tailoring the mouse cursor display<br>I530UL Non-touchable window<br>I530W5 Using JS APIs to listen for hot swap events of the remote control<br>I530W9 Using JS APIs to listen for hot swap events of the mouse<br>I530WB Using JS APIs to query extended information about the touchpad<br>I530W9 Using JS APIs to listen for hot swap events of the keyboard<br>I530UW Tailoring the configuration of combined keys| NA |
| System service management| Group verification is supported.<br>The following requirements are involved:<br>I59XYB Adding group verification<br>I53NZQ Processing the installation status and version number of a remote application<br>I568AO Reporting the association between distributed components by DMS<br>I58ZSB Collecting OS type information| NA |
| Bundle management| - Installation, uninstall, and query of sandbox applications are supported.<br>- The unpacking tool supports the stage model, and the capability of the packing tool is enhanced.<br>The following requirements are involved:<br>I524WG Specifying whether data of system applications can be cleared<br>I524WP Querying whether a specified application is installed<br>I524UF Supporting the update of system features (with entry installed)<br>I524VP Supporting ability priority for implicit query<br>I56W2U Supporting the BackupExtension type<br>I56W68 Packing pack.info into the HAP file<br>I56W6W Packing the old and new HAP files into the same APP Pack<br>I56W4O Extracting the rpcid file using the unpacking tool<br>I56W59 Parsing the stage model package using the unpacking tool<br>I56W7H Sending a scanning complete event after BMS scanning is complete<br>I56WIG Installation of sandbox applications<br>I56WIS Uninstall of sandbox applications<br>I56WJ7 Sandbox application information query| NA |
| Basic communications| Access from human-machine interface devices is supported.<br>The following requirement is involved:<br>I58ZUA Access from human-machine interface devices, such as Bluetooth keyboard, mouse, and game controller| NA |
| Ability| - The FA model supports ability-level screen orientation query and setting, lock screen display, and screen-on during ability startup.<br>- More DFX features are added, including ANR and suspension detection of an application's main thread.<br>- The stage model supports the Worker mechanism.<br>The following requirements are involved:<br>I58ZRH Ability-level screen orientation query and setting in the FA model<br>I58ZRI Lock screen display for an ability in the FA model<br>I58ZRJ Screen-on during ability startup in the FA model<br>I58ZRD Automatic generation of Extension JS server and client interface files using the ZIDL tool<br>I58ZR5 Interception of uncatched exceptions<br>I58ZR6 ANR processing<br>I58ZR7 Thread suspension detection of the ability manager service<br>I58ZR9 Suspension detection of an application's main thread<br>I58ZRA Timeout detection of ability lifecycle transition<br>I58ZR1 FA widget capability supplement - deleting invalid widgets<br>I58ZR2 FA widget capability supplement - separate setting of the visibility status and update status of widgets<br>I58ZQR Ability listeners<br>I58ZQW APIs related to the scheduling component lifecycle<br>I50DOL Worker mechanism in the stage model| NA |
| Multimedia| - The OpenSL ES recording APIs are added.<br>- The HiStreamer engine supports audio playback for the standard system.<br>The following requirements are involved:<br>I58ZOI Settings and obtaining the total volume<br>I58ZOJ Audio-related user permission control<br>I58ZOM OpenSL ES basic recording APIs<br>I59H9F Audio playback supported by the HiStreamer engine for the standard system| NA |
| Graphics| - Secure screen capturing and screen recording are supported.<br>- An application's window can be displayed in other applications.<br>The following requirements are involved:<br>I58ZOX GPU compositing supported by RenderService<br>I58ZOU Secure screen capturing and screen recording (security layer)<br>I58ZOW Cross-screen window display in the case of extended screens and splicing screens<br>I58ZOT Window embedding into other applications| NA |
| Window manager| - Quick switching to the home screen and restoration of application windows are supported.<br>- Screen wakeup by window is supported.<br>- The window can be used to keep the screen always on and adjusts the screen brightness.<br>- The security layer is supported.<br>- The window focusable and touchable attributes are added.<br>- The window orientation can be set.<br>- The window of an application can be displayed on a locked screen.<br>- Window decoration is supported.<br>- The main window of an application can be displayed in full screen.<br>- An application can exit window control.<br>- The application UI combination capability is provided for system applications.<br>The following requirements are involved:<br>I58ZP0 Setting of the display density<br>I58ZP1 Quick switching to the home screen and restoration of application windows<br>I58ZP4 Screen wakeup by window<br>I58ZP5 Screen always-on and screen brightness adjustment by window<br>I58ZP6 Security layer<br>I58ZP7 Obtaining the window focusable and touchable attributes<br>I58ZP8 Window orientation setting<br>I58ZPA Window display on a locked screen<br>I58ZPD Window decoration<br>I58ZPE Full-screen display for the main window<br>I58ZPG Exit window control by application<br>I58ZPI Window launch by application<br>I58ZPJ Application UI combination capability for system applications| NA |
| Network management| - WebSocket JS APIs are added.<br>- The **system.fetch** APIs are now compatible.<br>- The **system.network** APIs are now compatible.<br>The following requirements are involved:<br>I53CKH Supporting the **system.fetch** APIs<br>I53CKT WebSocket support<br>I53CJX Supporting the **system.network** APIs| NA |
| Globalization| - APIs for synchronously obtaining resources are provided. Resources can be obtained by resource name. Resources of the float type can be obtained.<br>- MCC/MNC qualifiers are supported.<br>- Independent compilation of different modules in an application is supported.<br>- The locale-specific date format is supported.<br>- Transliteration is supported, for example, converting Chinese characters into Hanyu Pinyin.<br>The following requirements are involved:<br>I596AO Supporting MCC/MNC qualifiers<br>I58ZSE Enhanced resource management APIs<br>I58ZSG Resource ID generation<br>I4WM02 Transliteration<br>I4WK2O Date format| NA |
| ArkUI | - The layout boundaries can be displayed for different components.<br>- The mouse operation of the **XComponent** is enhanced, the layout adjustment when the input method is displayed is optimized, and the application performance is optimized.<br>- The **\<Column>** and **\<SideBarContainer>** components can be automatically hidden when they are dragged to a width that is less than the minimum width.<br>- The **\<AbilityComponent>** component is added so an ability can be embedded into other applications as a component for display.<br>The following requirements are involved:<br>I58ZPY Decoding down-sampled images for higher performance<br>I58ZPX CPU frequency increase to optimize the animation performance<br>I58ZPW **\<AbilityComponent>** component support<br>I58ZPS **XComponent** mouse event<br>I58ZPR Automatic layout when the input method app is started from the text box<br>I58ZPQ Automatically hiding of the **\<Column>** and **\<SideBarContainer>** components when they are dragged to a width that is less than the minimum width<br>I58ZPP Layout boundary display for the drawing and auxiliary components<br>I58ZPO Layout boundary display for the button, selection, information display, and dynamic effect components<br>I58ZPN Layout boundary display for text, input, image, video, and media components| NA |
| Program access control| - Security Enhanced Linux (SELinux, also known as label protection) is provided for service and hdf_service.<br>- Permission configuration and validation capabilities are provided for native services.<br>The following requirements are involved:<br>I58ZO1 SELinux for service<br>I58ZO2 SELinux for hdf_service<br>I58ZO3 accessToken-based permission verification for native services| NA |
| Utils| TypedArray and SharedArrayBuffer support ECMAScript 2021.<br>The following requirements are involved:<br>I58ZPZ TypedArray ECMAScript 2021 support<br>I58ZQ0 SharedArrayBuffer ECMAScript 2021 support| NA |
| Multi-language runtime| Ark VMs support multi-instance debugging, conditional breakpoints, and watch expressions.<br>The following requirements are involved:<br>I58ZQE Multi-instance debugging<br>I58ZQD Conditional breakpoints<br>I58ZQB Watch variables and expressions<br>I58ZQ8 Code generated by the Ahead of Time (TSAOT) compiler supporting the garbage collector (GC) of ArkCompiler JS Runtime<br>I58ZQ7 Quality back-end machine code generated by the TSAOT compiler| NA |
| Update| Adaptation to RK3568 is added.<br>The following requirements are involved:<br>I58ZSM RK 3568 update adaptation support by update_service<br>I58ZSO RK 3568 update adaptation support by updater| NA |
| Misc services| The HTTP file upload and download APIs that were available before API version 6 are supplemented.<br>The following requirements are involved:<br>I58ZSC [download] Supporting the **\@system.request** APIs<br>I53J82 [upload] Supporting the **\@system.request** APIs| NA |
| File management| - Configuration of special sandboxes is supported.<br>- Third-party applications are provided with the storage query capability.<br>The following requirements are involved:<br>I58ZS6 Differentiated configuration of application sandboxes<br>I58ZS9 Storage query capability for third-party applications<br>I58ZSA Adaptation to new HUKS HAL APIs<br>I58ZS3 Version update of the distributed user data access framework| NA |
| Common event and notification| - Agent-powered notification is added to support sending of notifications on behalf of third-party applications.<br>- The notification slot query and setting capabilities are enhanced.<br>The following requirements are involved:<br>I582UB Agent-powered notification<br>I582TF Enhancement of notification slot setting and query| NA |
| Pan-sensor| The adaptation to the ambient light sensor is added.<br>The following requirements are involved:<br>I53784 Continuous integration of pan-sensor capabilities - ambient light sensor<br>I538PX System API synchronization| NA |
| Distributed data management| Distributed data object samples are added.<br>The following requirement is involved:<br>I4WO0S Distributed data object samples| NA |
| Driver| - Kernel drivers can be dynamically loaded.<br>- The HAL capability of the peripheral module is enhanced and the HDIs are optimized.<br>The following requirements are involved:<br>I4UD9W Dynamic driver loading in the kernel space to improve the device driver development and debugging efficiency<br>I54566 Rectification of the camera service and HDI cyclic dependency<br>I50I6S Unified audio APIs for the IPC mode and direct debugging mode<br>I54FQG Driver model of codec devices<br>I544XP SELinux permission check for the HDF service<br>I4UL98 ADC adaptation to the IIO framework of the Linux kernel| NA |
| Build| - The HAP files provided by the stage model can be compiled along with the code.<br>- Third-party open-source software can be used as an independent part. When other parts depend on this software, the build subsystem automatically installs the software to the image, without the need for the configuration in the product list.<br>- Python, Jinja2, and MarkupSafe are updated.<br>- The device type can be customized during build.<br>- The user and root versions are built separately.<br>- The strip operation can be configured for the precompiled module.<br>- The product configurations are normalized for different device types.<br>The following requirements are involved:<br>I53FCL The HAP files provided by the stage model can be compiled along with the code.<br>I54ZLX Third-party open-source software can be used as an independent part. When other parts depend on this software, the build subsystem automatically installs the software to the image, without the need for the configuration in the product list.<br>I54ERB/I52MRL/I52KTV Updating the open-source software that is identified as EOM by cleansource 3.1.<br>I5714O Customization of ohos.para<br>I4Q9MI Strip operation for the precompiled modules<br>I56M93 Normalized product configurations for different device types| - Python, Jinja2, and MarkupSafe are updated.<br>- The user and root versions are built separately.<br>The following requirements are involved:<br>I54ZLX Third-party open-source software can be used as an independent part. When other parts depend on this software, the build subsystem automatically installs the software to the image, without the need for the configuration in the product list.<br>I54ERB/I52MRL/I52KTV Updating the open-source software that is identified as EOM by cleansource 3.1.<br>I4Q9MI Strip operation for the precompiled modules|
| Test| - Test cases to be executed can be filtered by type, granularity, and level.<br>- The UI test framework provides APIs such as sliding search.<br>- The executor supports component-based execution and re-test of failed cases.<br>- The stability tool supports report parsing, generation, and display, and component injection.<br>The following requirements are involved:<br>I58ZUJ Test case filtering<br>I58ZUK Enhanced UI test framework capability: more APIs<br>I58ZUM Enhanced UI test framework capability: UI-dump function<br>I58ZUR Enhanced UI test framework capability: customized UI operation parameters<br>I58ZUS Configuration of the test scheduling framework<br>I58ZUU Componentization of the test scheduling framework<br>I58ZUV Parsing, generating, and displaying of stability reports by the stability tool<br>I58ZUW Component injection of the stability tool| NA |
| Basic security capabilities| Mutual authentication is now available between OpenHarmony devices based on the sample login account.<br>The following requirements are involved:<br>I58ZNS Mutual authentication between OpenHarmony devices based on the same login account<br>I58ZNR Removing account authentication credentials from OpenHarmony devices after an account is logged out or removed<br>I58ZNP Importing and removing of trust records of accounts from different vendors (same vendor or OEM vendor) for OpenHarmony devices<br>I58ZNT Importing of account authentication credentials (asymmetric credentials) to OpenHarmony devices after an account is logged in or bound| NA |
| System applications| The Gallery application supports image editing and dynamic effects.<br>The following requirements are involved:<br>I58ZQ3 [Gallery] Image editing<br>I58ZQ1 [Gallery] Dynamic effects<br>I58ZQ4 [Contacts] Basic capability - 2D capability| NA |
### API Updates
*[API Differences](api-change/v3.2-beta/readme.md)*
### Chip and Development Board Adaptation
For details about the adaptation status, see [SIG-Devboard](https://gitee.com/openharmony/community/blob/master/sig/sig-devboard/sig_devboard.md).
### Samples
**Table 4** New samples
| Subsystem| Sample| Introduction| Programming Language|
| -------- | -------- | -------- | -------- |
| ArkUI | MouseEvent | This sample simulates a minesweeper game that calls mouse event-related APIs.| eTS |
| ArkUI | Vibrator | This sample simulates the countdown scenario to show the use of the vibrator APIs.| eTS |
| DFX | FaultLogger | This sample illustrates how to obtain fault information of an application in eTS.| eTS |
| ArkUI | Gallery | This sample demonstrates the functions of different components such as universal events, universal attributes, and gestures.| eTS |
| Graphics| JsWebGL | This sample shows how to use WebGL APIs to draw pentagrams and rectangles by invoking GPU resources.| JS |
| ArkUI | Clock | This sample exemplifies how to implement a simple clock application using the eTS UI capability.| eTS |
| Network management| Http | This sample simulates Postman, which requires the input of an API address and outputs the data obtained, to show the use of the data request APIs.| eTS |
| ArkUI | FlishLight | This sample simulates a flashlight by changing the screen brightness. If the screen becomes brighter, the flashlight is turned on. If the screen becomes darker, the flashlight is turned off.| eTS |
| Network management| Socket | This sample demonstrates the application of Socket in network communication, including connection authentication and chat communication between two devices.| eTS |
| Distributed data management| DistributedRdb | This sample shows how to add, delete, modify, query, and synchronize data in the distributed relational database with eTS.| eTS |
| Ability| BackgroundTaskManager | This sample simulates the download function. Being processed by the background task management, a download task can continue after the application exits. It stops until the download is complete.| eTS |
| Ability| BringApp | This sample uses the **FeatureAbility** APIs to start a system application based on the application's bundle name and ability name.| eTS |
| Media| VideoPlayer | This sample shows how to play a video using the **VideoPlayer** APIs in eTS. It also provides an ability that can be invoked by other applications to play the video.| eTS |
| Ability| DistributeCalc | This sample implements a simple calculator application using JS distributed features. The calculator can perform simple numerical calculations and start a remote calculator FA to perform collaborative calculation.| eTS |
| Multimedia| JSRecorder | This sample shows how to implement audio recording and playback by calling media-related APIs.| eTS |
| Web | Browser | This sample uses the stage model and related APIs to show a simple browser.| eTS |
| Ability| DeviceUsageStatistics | This sample shows the device usage statistics.| eTS |
| ArkUI | AdaptiveCapabilities | This sample shows multi-device adaptation in eTS, including resource qualifiers, atomic layouts, and responsive layouts.| eTS |
| ArkUI | Game2048 | This sample shows how to develop a 2048 game using the **\<Grid>** component.| eTS |
| Window Manager| Window | This sample shows how to create a window, display an application over another application in the form of a floating window, and display an application on split screens.| eTS |
| Distributed data management| Preference | This sample shows the theme switching function of preferences.| eTS |
| ArkUI | NativeAPI | This sample shows how to call C++ APIs in eTS and how C++ APIs call back JS APIs to play the Gomoku game. The native APIs implement the calculation logic, and eTS implements UI rendering and re-rendering.| eTS/C++ |
| Globalization| International | This sample shows how to use APIs related to i18n, intl, and resourceManager in eTS to set the system language, region, time, and time zone. It also provides locale setting examples.| eTS |
For more information, visit [Samples](https://gitee.com/openharmony/app_samples).
## Resolved Issues
**Table 5** Resolved issues
| Issue No. | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [I4NRS5](https://gitee.com/openharmony/kernel_linux_5.10/issues/I4NRS5) | [Kernel subsystem] A CVE vulnerability exists. |
## Known Issues
**Table 6** Known issues
| Issue No. | Description | Impact | To Be Resolved By|
| ------------------------------------------------------------ | ---------------------------------------------------------- | ------------------------------------------------------------ | ------------ |
| [I4Z3G9](https://gitee.com/openharmony/graphic_graphic_2d/issues/I4Z3G9) | [RK3568] Screen flickering occurs when the secondary window is opened in the immersive primary window.| Developer experience is affected. | 2022-06-15 |
| [I59M4Q](https://gitee.com/openharmony/developtools_hdc/issues/I59M4Q) | There is a low probability that the device is disconnected when hdc_std of API version 9 is used to connect to the device. | This issue occurs at a low probability (less than 1/30). It can be resolved by restarting the IDE or hdc_std.| 2022-06-30 |
| [I54D32](https://gitee.com/openharmony/multimedia_camera_standard/issues/I54D32) | [RK3568] A black screen is displayed when the camera has been recording videos for multiple consecutive times. | Developer experience is affected. | 2022-06-15 |
# OpenHarmony Release Notes
## OpenHarmony 3.x Releases
- [OpenHarmony v3.2 Beta1 (2022-05-31)](OpenHarmony-v3.2-beta1.md)
- [OpenHarmony v3.1.1 Release (2022-05-31)](OpenHarmony-v3.1.1-release.md)
- [OpenHarmony v3.1 Release (2022-03-30)](OpenHarmony-v3.1-release.md)
- [OpenHarmony v3.1 Beta (2021-12-31)](OpenHarmony-v3.1-beta.md)
- [OpenHarmony v3.0.3 LTS (2022-04-08)](OpenHarmony-v3.0.3-LTS.md)
......
# JS API Changes of the Resource Scheduling Subsystem
# JS API Changes of the Distributed Scheduler Subsystem
The table below lists the APIs changes of the resource scheduling subsystem in OpenHarmony 3.1 Release over OpenHarmony 3.0 LTS.
The table below lists the APIs changes of the distributed scheduler subsystem in OpenHarmony 3.1 Release over OpenHarmony 3.0 LTS.
## API Changes
......
......@@ -9,10 +9,10 @@ For details about the JS API changes in OpenHarmony 3.1 Release over OpenHarmony
- [Bundle management subsystem](js-apidiff-bundle.md)
- [Communication subsystem](js-apidiff-communicate.md)
- [Multi-language Runtime subsystem](js-apidiff-compiler-and-runtime.md)
- [DFX](js-apidiff-dfx.md)
- [DFX subsystem](js-apidiff-dfx.md)
- [Distributed data management subsystem](js-apidiff-distributed-data.md)
- [Distributed hardware subsystem](js-apidiff-distributed-hardware.md)
- [Common event and notification framework](js-apidiff-event-and-notification.md)
- [Common event and notification subsystem](js-apidiff-event-and-notification.md)
- [File management subsystem](js-apidiff-file-management.md)
- [Location subsystem](js-apidiff-geolocation.md)
- [Globalization subsystem](js-apidiff-global.md)
......@@ -21,7 +21,7 @@ For details about the JS API changes in OpenHarmony 3.1 Release over OpenHarmony
- [Multimodal input subsystem](js-apidiff-multi-modal-input.md)
- [Multimedia subsystem](js-apidiff-multimedia.md)
- [Network management subsystem](js-apidiff-network.md)
- [Resource scheduling subsystem](js-apidiff-resource-scheduler.md)
- [Distributed scheduler subsystem](js-apidiff-resource-scheduler.md)
- [Security subsystem](js-apidiff-security.md)
- [Pan-sensor subsystem](js-apidiff-sensor.md)
- [Application framework subsystem](js-apidiff-settings.md)
......
# JS API Changes of the Common Event and Notification Framework
# JS API Changes of the Common Event and Notification Subsystem
The table below lists the APIs changes of the common event and notification framework in OpenHarmony 3.2 Beta1 over OpenHarmony 3.1 Release.
The table below lists the APIs changes of the common event and notification subsystem in OpenHarmony 3.2 Beta1 over OpenHarmony 3.1 Release.
## API Changes
......
# JS API Changes of the Resource Scheduler Subsystem
# JS API Changes of the Distributed Scheduler Subsystem
The table below lists the APIs changes of the resource scheduler subsystem in OpenHarmony 3.2 Beta1 over OpenHarmony 3.1 Release.
The table below lists the APIs changes of the distributed scheduler subsystem in OpenHarmony 3.2 Beta1 over OpenHarmony 3.1 Release.
## API Changes
......
# JS API Changes of the Testing Framework Subsystem
# JS API Changes of the Test Subsystem
The table below lists the APIs changes of the testing framework subsystem in OpenHarmony 3.2 Beta1 over OpenHarmony 3.1 Release.
The table below lists the APIs changes of the test subsystem in OpenHarmony 3.2 Beta1 over OpenHarmony 3.1 Release.
## API Changes
......
......@@ -4,22 +4,22 @@ This directory records the API changes in OpenHarmony 3.2 Beta1 over OpenHarmony
- JS API Differences
- [Ability framework](js-apidiff-ability.md)
- [ArkUI Development Framework](js-apidiff-arkui.md)
- [ArkUI development framework](js-apidiff-arkui.md)
- [Power management subsystem](js-apidiff-battery.md)
- [Bundle management framework](js-apidiff-bundle.md)
- [Communication subsystem](js-apidiff-communicate.md)
- [DFX subsystem](js-apidiff-dfx.md)
- [Distributed data management subsystem](js-apidiff-distributed-data.md)
- [Common event and notification framework](js-apidiff-event-and-notification.md)
- [Common event and notification subsystem](js-apidiff-event-and-notification.md)
- [File management subsystem](js-apidiff-file-management.md)
- [Globalization subsystem](js-apidiff-global.md)
- [Startup subsystem](js-apidiff-init.md)
- [Misc services subsystem](js-apidiff-misc.md)
- [Multimodal input subsystem](js-apidiff-multi-modal-input.md)
- [Multimedia subsystem](js-apidiff-multimedia.md)
- [Resource scheduler subsystem](js-apidiff-resource-scheduler.md)
- [Distributed scheduler subsystem](js-apidiff-resource-scheduler.md)
- [DSoftBus subsystem](js-apidiff-soft-bus.md)
- [Testing framework subsystem](js-apidiff-unitest.md)
- [Test subsystem](js-apidiff-unitest.md)
- [Web subsystem](js-apidiff-web.md)
- [Window manager subsystem](js-apidiff-window.md)
- [Native API Differences](native-apidiff-v3.2-beta.md)
......@@ -4,23 +4,85 @@
- [Glossary](glossary.md)
- OpenHarmony Release Notes
- OpenHarmony 3.x Releases
- [OpenHarmony v3.2 Beta1 (2022-05-31)](release-notes/OpenHarmony-v3.2-beta1.md)
- [OpenHarmony v3.1.1 Release (2022-05-31)](release-notes/OpenHarmony-v3.1.1-release.md)
- [OpenHarmony v3.1 Release (2022-03-30)](release-notes/OpenHarmony-v3.1-release.md)
- [OpenHarmony v3.1 Beta (2021-12-31)](release-notes/OpenHarmony-v3.1-beta.md)
- [OpenHarmony v3.0.3 LTS (2022-04-08)](release-notes/OpenHarmony-v3.0.3-LTS.md)
- [OpenHarmony v3.0.2 LTS (2022-03-18)](release-notes/OpenHarmony-v3.0.2-LTS.md)
- [OpenHarmony v3.0.1 LTS (2022-01-12)](release-notes/OpenHarmony-v3.0.1-LTS.md)
- [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md)
- [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md)
- OpenHarmony 2.x Releases
- [OpenHarmony v2.2 beta2 (2021-08-04)](release-notes/OpenHarmony-v2.2-beta2.md)
- [OpenHarmony 2.0 Canary (2021-06-01)](release-notes/OpenHarmony-2-0-Canary.md)
- OpenHarmony 1.x Releases
- [OpenHarmony v1.1.4 LTS (2022-02-11)](release-notes/OpenHarmony-v1-1-4-LTS.md)
- [OpenHarmony v1.1.3 LTS (2021-09-30)](release-notes/OpenHarmony-v1-1-3-LTS.md)
- [OpenHarmony v1.1.2 LTS (2021-08-04)](release-notes/OpenHarmony-v1.1.2-LTS.md)
- [OpenHarmony 1.1.1 LTS (2021-06-22)](release-notes/OpenHarmony-1-1-1-LTS.md)
- [OpenHarmony 1.1.0 LTS (2021-04-01)](release-notes/OpenHarmony-1-1-0-LTS.md)
- [OpenHarmony 1.0 (2020-09-10)](release-notes/OpenHarmony-1-0.md)
- API Differences
- OpenHarmony 3.2 Beta1
- JS API Differences
- [Ability framework](release-notes/api-change/v3.2-beta/js-apidiff-ability.md)
- [ArkUI development framework](release-notes/api-change/v3.2-beta/js-apidiff-arkui.md)
- [Power management subsystem](release-notes/api-change/v3.2-beta/js-apidiff-battery.md)
- [Bundle management framework](release-notes/api-change/v3.2-beta/js-apidiff-bundle.md)
- [Communication subsystem](release-notes/api-change/v3.2-beta/js-apidiff-communicate.md)
- [DFX subsystem](release-notes/api-change/v3.2-beta/js-apidiff-dfx.md)
- [Distributed data management subsystem](release-notes/api-change/v3.2-beta/js-apidiff-distributed-data.md)
- [Common event and notification subsystem](release-notes/api-change/v3.2-beta/js-apidiff-event-and-notification.md)
- [File management subsystem](release-notes/api-change/v3.2-beta/js-apidiff-file-management.md)
- [Globalization subsystem](release-notes/api-change/v3.2-beta/js-apidiff-global.md)
- [Startup subsystem](release-notes/api-change/v3.2-beta/js-apidiff-init.md)
- [Misc services subsystem](release-notes/api-change/v3.2-beta/js-apidiff-misc.md)
- [Multimodal input subsystem](release-notes/api-change/v3.2-beta/js-apidiff-multi-modal-input.md)
- [Multimedia subsystem](release-notes/api-change/v3.2-beta/js-apidiff-multimedia.md)
- [Distributed scheduler subsystem](release-notes/api-change/v3.2-beta/js-apidiff-resource-scheduler.md)
- [DSoftBus subsystem](release-notes/api-change/v3.2-beta/js-apidiff-soft-bus.md)
- [Test subsystem](release-notes/api-change/v3.2-beta/js-apidiff-unitest.md)
- [Web subsystem](release-notes/api-change/v3.2-beta/js-apidiff-web.md)
- [Window manager subsystem](release-notes/api-change/v3.2-beta/js-apidiff-window.md)
- [Native API Differences](release-notes/api-change/v3.2-beta/native-apidiff-v3.2-beta.md)
- OpenHarmony 3.1 Release
- JS API Differences (API Version 8)
- [Ability framework](release-notes/api-change/v3.1-Release/js-apidiff-ability.md)
- [Accessibility subsystem](release-notes/api-change/v3.1-Release/js-apidiff-accessibility.md)
- [Account subsystem](release-notes/api-change/v3.1-Release/js-apidiff-account.md)
- [ArkUI development framework](release-notes/api-change/v3.1-Release/js-apidiff-ace.md)
- [Power management subsystem](release-notes/api-change/v3.1-Release/js-apidiff-battery.md)
- [Bundle management subsystem](release-notes/api-change/v3.1-Release/js-apidiff-bundle.md)
- [Communication subsystem](release-notes/api-change/v3.1-Release/js-apidiff-communicate.md)
- [Multi-language Runtime subsystem](release-notes/api-change/v3.1-Release/js-apidiff-compiler-and-runtime.md)
- [DFX subsystem](release-notes/api-change/v3.1-Release/js-apidiff-dfx.md)
- [Distributed data management subsystem](release-notes/api-change/v3.1-Release/js-apidiff-distributed-data.md)
- [Distributed hardware subsystem](release-notes/api-change/v3.1-Release/js-apidiff-distributed-hardware.md)
- [Common event and notification subsystem](release-notes/api-change/v3.1-Release/js-apidiff-event-and-notification.md)
- [File management subsystem](release-notes/api-change/v3.1-Release/js-apidiff-file-management.md)
- [Location subsystem](release-notes/api-change/v3.1-Release/js-apidiff-geolocation.md)
- [Globalization subsystem](release-notes/api-change/v3.1-Release/js-apidiff-global.md)
- [Graphics subsystem](release-notes/api-change/v3.1-Release/js-apidiff-graphic.md)
- [Misc services subsystem](release-notes/api-change/v3.1-Release/js-apidiff-misc.md)
- [Multimodal input subsystem](release-notes/api-change/v3.1-Release/js-apidiff-multi-modal-input.md)
- [Multimedia subsystem](release-notes/api-change/v3.1-Release/js-apidiff-multimedia.md)
- [Network management subsystem](release-notes/api-change/v3.1-Release/js-apidiff-network.md)
- [Distributed scheduler subsystem](release-notes/api-change/v3.1-Release/js-apidiff-resource-scheduler.md)
- [Security subsystem](release-notes/api-change/v3.1-Release/js-apidiff-security.md)
- [Pan-sensor subsystem](release-notes/api-change/v3.1-Release/js-apidiff-sensor.md)
- [Application framework subsystem](release-notes/api-change/v3.1-Release/js-apidiff-settings.md)
- [DSoftBus subsystem](release-notes/api-change/v3.1-Release/js-apidiff-soft-bus.md)
- [Telephony subsystem](release-notes/api-change/v3.1-Release/js-apidiff-telephony.md)
- [USB subsystem](release-notes/api-change/v3.1-Release/js-apidiff-usb.md)
- [User IAM subsystem](release-notes/api-change/v3.1-Release/js-apidiff-user-authentication.md)
- [Window manager subsystem](release-notes/api-change/v3.1-Release/js-apidiff-window.md)
- [Native API Differences](release-notes/api-change/v3.1-Release/native-apidiff-v3.1-release.md)
- Contribution
- [How to Contribute](contribute/how-to-contribute.md)
- [Code of Conduct](contribute/code-of-conduct.md)
......
......@@ -8,12 +8,12 @@
## 接口说明
| 模块 | 接口名 | 描述 |
| -------- | -------- | -------- |
| ohos.vibrator | vibrate(duration:&nbsp;number):&nbsp;Promise&lt;void&gt; | 触发马达按照时长振动,Promise型。 |
| ohos.vibrator | vibrate(duration:&nbsp;number,&nbsp;callback?:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | 触发马达按照时长振动,Callback型。 |
| ohos.vibrator | vibrate(effectId:&nbsp;EffectId):&nbsp;Promise&lt;void&gt; | 触发马达按照指定字符串振动,Promise型。 |
| ohos.vibrator | vibrate(effectId:&nbsp;EffectId,&nbsp;callback?:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | 触发马达按照指定字符串振动,Callback型。 |
| 模块 | 接口名 | 描述 |
| ------------- | ---------------------------------------- | ------------------------------- |
| ohos.vibrator | vibrate(duration:&nbsp;number):&nbsp;Promise&lt;void&gt; | 触发马达按照时长振动,使用Promise异步回调。 |
| ohos.vibrator | vibrate(duration:&nbsp;number,&nbsp;callback?:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | 触发马达按照时长振动,使用Callback异步回调。 |
| ohos.vibrator | vibrate(effectId:&nbsp;EffectId):&nbsp;Promise&lt;void&gt; | 触发马达按照开发者传递效果振动,使用Promise异步回调。 |
| ohos.vibrator | vibrate(effectId:&nbsp;EffectId,&nbsp;callback?:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | 触发马达按照开发者传递效果振动,使用Callback异步回调。 |
| ohos.vibrator | stop(stopMode:&nbsp;VibratorStopMode):&nbsp;Promise&lt;void&gt; | 停止振动。 |
| ohos.vibrator | stop(stopMode:&nbsp;VibratorStopMode,&nbsp;callback?:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | 停止振动。 |
......
......@@ -507,7 +507,7 @@ extensionAbility示例 :
| 属性名称 | 含义 | **类型** | **取值范围** | **默认值** | **规则约束** |
| --------- | ------------------------------------------------------------ | ------------------------------- | ----------------------------------------------------------- | ---------------------- | ------------------------------------------------------------ |
| name | 必须,填写需要使用的权限名称。 | 字符串 | 自定义 | 无 | 未填写时,解析失败。 |
| reason | 可选,当申请的权限为user_grant权限时此字段必填。描述申请权限的原因。 | 字符串 | 显示文字长度不能超过256个字节。 | 空 | user_grant权限必填,否则不允许在应用市场上架。需做多语种适配。 |
| reason | 可选,当申请的权限为user_grant权限时此字段必填。描述申请权限的原因。 | 字符串 | 使用string类资源引用。格式为`$string: ***` | 空 | user_grant权限必填,否则不允许在应用市场上架。需做多语种适配。 |
| usedScene | 可选,当申请的权限为user_grant权限时此字段必填。描述权限使用的场景和时机。场景类型有 :ability、when(调用时机)。可配置多个ability。 | ability :字符串数组when :字符串 | ability :ability的名称when :inuse(使用时)、always(始终) | ability :空when :inuse | user_grant权限必填ability,可选填when。 |
requestPermissions示例 :
......
......@@ -90,7 +90,8 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
- 在second.ets文件中,将本页面的message文本内容设置为“Hi there”,示例如下:
```
```ts
// second.ets
@Entry
@Component
struct Second {
......@@ -123,7 +124,8 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。需同时处理ets文件及visual文件。
-**index.ets**”示例如下:
```
```ts
// index.ets
import router from '@ohos.router';
@Entry
......@@ -155,7 +157,8 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
-**second.ets**”示例如下:
```
```ts
// second.ets
import router from '@ohos.router';
@Entry
......
......@@ -43,7 +43,8 @@
工程同步完成后,在“**Project**”窗口,点击“**entry &gt; src &gt; main &gt; ets &gt; MainAbility &gt; pages**”,打开“**index.ets**”文件,可以看到页面由Text组件组成。“**index.ets**”文件的示例如下:
```
```ts
// index.ets
@Entry
@Component
struct Index {
......@@ -67,7 +68,8 @@
在默认页面基础上,我们添加一个Button组件,作为按钮响应用户点击,从而实现跳转到另一个页面。“**index.ets**”文件的示例如下:
```
```ts
// index.ets
@Entry
@Component
struct Index {
......@@ -116,7 +118,8 @@
参照第一个页面,在第二个页面添加Text组件、Button组件等,并设置其样式。“**second.ets**”文件的示例如下:
```
```ts
// second.ets
@Entry
@Component
struct Second {
......@@ -157,7 +160,8 @@
在第一个页面中,跳转按钮绑定onClick事件,点击按钮时跳转到第二页。“**index.ets**”文件的示例如下:
```
```ts
// index.ets
import router from '@ohos.router';
@Entry
......@@ -200,7 +204,8 @@
在第二个页面中,返回按钮绑定onClick事件,点击按钮时返回到第一页。“**second.ets**”文件的示例如下:
```
```ts
// second.ets
import router from '@ohos.router';
@Entry
......
......@@ -43,7 +43,8 @@
工程同步完成后,在“**Project**”窗口,点击“**entry &gt; src &gt; main &gt; js &gt; MainAbility &gt; pages&gt; index**”,打开“**index.hml**”文件,设置Text组件内容。“**index.hml**”文件的示例如下:
```
```html
<!--index.hml-->
<div class="container">
<text class="title">
Hello World
......@@ -55,7 +56,8 @@
在默认页面基础上,我们添加一个button类型的input组件,作为按钮响应用户点击,从而实现跳转到另一个页面。“**index.hml**”文件的示例代码如下:
```
```html
<!--index.hml-->
<div class="container">
<text class="title">
Hello World
......@@ -70,7 +72,7 @@
在“**Project**”窗口,点击“**entry &gt; src &gt; main &gt; js &gt; MainAbility &gt; pages&gt; index**”,打开“**index.css**”文件,可以对页面中文本、按钮设置宽高、字体大小、间距等样式。“**index.css**”文件的示例如下:
```
```css
.container {
display: flex;
flex-direction: column;
......@@ -117,7 +119,8 @@
参照第一个页面,在第二个页面添加文本、按钮及点击按钮绑定页面返回等。“**second.hml**”文件的示例如下:
```
```html
<!--second.hml-->
<div class="container">
<text class="title">
Hi there
......@@ -130,7 +133,7 @@
3. 设置页面样式。“**second.css**”文件的示例如下:
```
```css
.container {
display: flex;
flex-direction: column;
......@@ -169,7 +172,8 @@
在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。“**index.js**”示例如下:
```
```js
// index.js
import router from '@ohos.router';
export default {
......@@ -185,7 +189,8 @@
在第二个页面中,返回按钮绑定back方法,点击按钮时返回到第一页。“**second.js**”示例如下:
```
```js
// second.js
import router from '@ohos.router';
export default {
......
......@@ -19,7 +19,6 @@
- [@ohos.application.formError (FormError)](js-apis-formerror.md)
- [@ohos.application.formHost (FormHost)](js-apis-formhost.md)
- [@ohos.application.formInfo (FormInfo)](js-apis-formInfo.md)
- [@ohos.application.missionInfo (MissionInfo)](js-apis-application-missionInfo.md)
- [@ohos.application.missionManager (missionManager)](js-apis-missionManager.md)
- [@ohos.application.formProvider (FormProvider)](js-apis-formprovider.md)
- [@ohos.ability.particleAbility (particleAbility模块)](js-apis-particleAbility.md)
......
......@@ -1564,6 +1564,126 @@ const receiver = function onReceive(err, data) {
bundle.queryExtensionAbilityInfos(want, extensionType, extensionFlags, receiver)
```
## bundle.getProfileByAbility<sup>9+</sup>
getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string>>): void;
以异步方法根据给定的moduleName,abilityName,metadataName来获取[metadata](js-apis-bundle-Metadata.md)中的配置文件的json字符串,使用callback形式返回结果。 该接口只能用来获取当前应用的配置文件的json字符串,不能在当前应用获取其他应用的配置文件json字符串。
**系统能力:** SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| moduleName | string | 是 | 表示要获取的配置文件所属的module。 |
| abilityName | string | 是 | 表示要获取的配置文件所属的ability。 |
| metadataName | string | 是 | 表示要获取的配置文件所属的metadata。 |
| callback | AsyncCallback\<Array\<string>> | 是 | 程序启动作为入参的回调函数,返回配置文件的json字符串数组。 |
**示例:**
```js
let moduleName = 'entry';
let abilityName = 'MainAbility';
let metadataName = 'ohos.ability.shortcuts';
const caller = function callback(err, data) {
console.error('Operation errcode is: ' + err);
console.error('Operation result is: ' + data);
}
bundle.getProfileByAbility(moduleName, abilityName, metadataName, caller)
```
## bundle.getProfileByAbility<sup>9+</sup>
getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\<Array\<string>>;
以异步方法根据给定的moduleName,abilityName,metadataName来获取[metadata](js-apis-bundle-Metadata.md)中的配置文件的json字符串,使用Promise形式返回结果。 该接口只能用来获取当前应用的配置文件的json字符串,不能在当前应用获取其他应用的配置文件json字符串。
**系统能力:** SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| moduleName | string | 是 | 表示要获取的配置文件所属的module。 |
| abilityName | string | 是 | 表示要获取的配置文件所属的ability。 |
| metadataName | string | 否 | 表示要获取的配置文件所属的[metadata](js-apis-bundle-Metadata.md)。 |
**示例:**
```js
let moduleName = 'entry';
let abilityName = 'MainAbility';
let metadataName = 'ohos.ability.shortcuts';
bundle.getProfileByAbility(moduleName, abilityName, metadataName).then(data=>{
console.error('Operation result is: ' + data);
}).catch(err=>{
console.error('Operation errcode is: ' + err);
})
```
## bundle.getProfileByExtensionAbility<sup>9+</sup>
getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string>>): void;
以异步方法根据给定的moduleName,extensionAbilityName,metadataName来获取[metadata](js-apis-bundle-Metadata.md)中的配置文件的json字符串,使用callback形式返回结果。 该接口只能用来获取当前应用的配置文件的json字符串,不能在当前应用获取其他应用的配置文件json字符串。
**系统能力:** SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| moduleName | string | 是 | 表示要获取的配置文件所属的module。 |
| extensionAbilityName | string | 是 | 表示要获取的配置文件所属的extensionAbility。 |
| metadataName | string | 是 | 表示要获取的配置文件所属的[metadata](js-apis-bundle-Metadata.md)。 |
| callback | AsyncCallback\<Array\<string>> | 是 | 程序启动作为入参的回调函数,返回配置文件的json字符串数组。 |
**示例:**
```js
let moduleName = 'entry';
let extensionAbilityName = 'Form';
let metadataName = 'ohos.extension.form';
const caller = function callback(err, data) {
console.error('Operation errcode is: ' + err);
console.error('Operation result is: ' + data);
}
bundle.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName, caller)
```
## bundle.getProfileByExtensionAbility<sup>9+</sup>
getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\<Array\<string>>;
以异步方法根据给定的moduleName,extensionAbilityName,metadataName来获取[metadata](js-apis-bundle-Metadata.md)中的配置文件的json字符串,使用Promise形式返回结果。 该接口只能用来获取当前应用的配置文件的json字符串,不能在当前应用获取其他应用的配置文件json字符串。
**系统能力:** SystemCapability.BundleManager.BundleFramework
**参数:**
| 名称 | 类型 | 必填 | 描述 |
| ---------------- | ---------------------------------- | ---- | ---------------------------------------- |
| moduleName | string | 是 | 表示要获取的配置文件所属的module。 |
| extensionAbilityName | string | 是 | 表示要获取的配置文件所属的extensionAbility。 |
| metadataName | string | 否 | 表示要获取的配置文件所属的metadata。 |
**示例:**
```js
let moduleName = 'entry';
let extensionAbilityName = 'Form';
let metadataName = 'ohos.extension.form';
bundle.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataName).then(data=>{
console.error('Operation result is: ' + data);
}).catch(err=>{
console.error('Operation errcode is: ' + err);
})
```
## InstallErrorCode
**系统能力:** SystemCapability.BundleManager.BundleFramework
......
......@@ -24,12 +24,12 @@ createAppAccountManager(): AppAccountManager
**返回值:**
| 类型 | 说明 |
| ----------------- | ------------------------ |
| ----------------- | ------------ |
| AppAccountManager | 获取应用帐号模块的实例。 |
**示例:**
```js
var appAccountManager = account.createAppAccountManager();
var appAccountManager = account_appAccount.createAppAccountManager();
```
## AppAccountManager
......@@ -47,7 +47,7 @@ addAccount(name: string, callback: AsyncCallback&lt;void&gt;): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------------------------- |
| -------- | ------------------------- | ---- | -------------------- |
| name | string | 是 | 要添加的应用帐号名称。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 将此应用的帐号名添加到帐号管理服务回调。 |
......@@ -71,7 +71,7 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| name | string | 是 | 要添加的应用帐号名称。 |
| extraInfo | string | 是 | 要添加的应用帐号的额外信息(能转换string类型的其它信息,如token等),额外信息不能是应用帐号的敏感信息(如应用账号密码)。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 将此应用程序的帐号名和额外信息添加到帐号管理服务中回调。 |
......@@ -98,14 +98,14 @@ addAccount(name: string, extraInfo: string): Promise&lt;void&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ------------------------------------------------------------ |
| --------- | ------ | ---- | ---------------------------------------- |
| name | string | 是 | 要添加的应用帐号名称。 |
| extraInfo | string | 是 | 要添加的应用帐号的额外信息(能转换成string类型的其它信息),额外信息不能是应用帐号的敏感信息(如应用账号密码)。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ----------------------------------- |
| ------------------- | --------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -130,7 +130,7 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------------------------------- |
| -------- | --------------------- | ---- | ----------------------- |
| owner | string | 是 | 要添加的应用帐号所有者包名。 |
| authType | string | 是 | 要添加的应用帐号鉴权类型。鉴权类型为自定义。 |
| options | {[key: string]: any} | 是 | 鉴权所需要的可选项。可选项可根据自己需要设置。 |
......@@ -171,7 +171,7 @@ deleteAccount(name: string, callback: AsyncCallback&lt;void&gt;): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | -------------------------------- |
| -------- | ------------------------- | ---- | ---------------- |
| name | string | 是 | 要删除的应用帐号名称。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 帐号管理服务中删除应用帐号回调。 |
......@@ -195,13 +195,13 @@ deleteAccount(name: string): Promise&lt;void&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------- |
| ---- | ------ | ---- | ----------- |
| name | string | 是 | 要删除的应用帐号名称。 |
**返回值:**
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| :------------------ | :-------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -226,7 +226,7 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;vo
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ------------------------------------------------------------ |
| ---------- | ------------------------- | ---- | --------------------------------- |
| name | string | 是 | 要禁用访问的第三方应用帐号名称。 |
| bundleName | string | 是 | 第三方应用的包名。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 禁止指定第三方应用帐号名称对指定包名称的第三方应用的回调进行访问。 |
......@@ -251,14 +251,14 @@ disableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | -------------------------------- |
| ---------- | ------ | ---- | ---------------- |
| name | string | 是 | 要禁用访问的第三方应用帐号名称。 |
| bundleName | string | 是 | 第三方应用的包名。 |
**返回值:**
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| :------------------ | :-------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -283,7 +283,7 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;voi
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ------------------------------------------------------------ |
| ---------- | ------------------------- | ---- | --------------------------------- |
| name | string | 是 | 应用帐号名称。 |
| bundleName | string | 是 | 第三方应用的包名。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 允许指定第三方应用帐号名称对指定包名称的第三方应用的回调进行访问。 |
......@@ -308,14 +308,14 @@ enableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ------------------ |
| ---------- | ------ | ---- | --------- |
| name | string | 是 | 应用帐号名称。 |
| bundleName | string | 是 | 第三方应用的包名。 |
**返回值:**
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| :------------------ | :-------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -341,7 +341,7 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback&lt;boolean&gt;):
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ------------------------------------------ |
| -------- | ---------------------------- | ---- | --------------------- |
| name | string | 是 | 应用帐号名称。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 检查指定应用帐号是否允许应用数据同步回调。 |
......@@ -368,13 +368,13 @@ checkAppAccountSyncEnable(name: string): Promise&lt;boolean&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------- |
| ---- | ------ | ---- | ------- |
| name | string | 是 | 应用帐号名称。 |
**返回值:**
| 类型 | 说明 |
| :--------------------- | :---------------------------------- |
| :--------------------- | :-------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -399,7 +399,7 @@ setAccountCredential(name: string, credentialType: string, credential: string,ca
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------------------------- | ---- | -------------------------- |
| -------------- | ------------------------- | ---- | ------------- |
| name | string | 是 | 应用程序帐号名称。 |
| credentialType | string | 是 | 要设置的凭据类型。 |
| credential | string | 是 | 要设置的凭据。 |
......@@ -425,7 +425,7 @@ setAccountCredential(name: string, credentialType: string, credential: string):
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------ | ---- | -------------------- |
| -------------- | ------ | ---- | ---------- |
| name | string | 是 | 应用帐号的名称。 |
| credentialType | string | 是 | 要设置的凭据的类型。 |
| credential | string | 是 | 要设置的凭据。 |
......@@ -433,7 +433,7 @@ setAccountCredential(name: string, credentialType: string, credential: string):
**返回值:**
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| :------------------ | :-------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -458,7 +458,7 @@ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback&lt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ------------------------------ |
| --------- | ------------------------- | ---- | --------------- |
| name | string | 是 | 应用帐号名称。 |
| extraInfo | string | 是 | 要设置的额外信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置此应用帐号的额外信息回调。 |
......@@ -483,14 +483,14 @@ setAccountExtraInfo(name: string, extraInfo: string): Promise&lt;void&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ------------------ |
| --------- | ------ | ---- | --------- |
| name | string | 是 | 应用帐号名称。 |
| extraInfo | string | 是 | 要设置的额外信息。 |
**返回值:**
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| :------------------ | :-------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -517,7 +517,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | -------------------------------------------------- |
| -------- | ------------------------- | ---- | ------------------------- |
| name | string | 是 | 应用帐号名称。 |
| isEnable | boolean | 是 | 是否允许应用数据同步。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置指定的应用帐号是否允许应用程序数据同步的回调。 |
......@@ -544,14 +544,14 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise&lt;void&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------- | ---- | ---------------------- |
| -------- | ------- | ---- | ----------- |
| name | string | 是 | 应用帐号名称。 |
| isEnable | boolean | 是 | 是否允许应用数据同步。 |
**返回值:**
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| :------------------ | :-------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -576,7 +576,7 @@ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallb
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------------------- |
| -------- | ------------------------- | ---- | ----------------- |
| name | string | 是 | 应用帐号名称。 |
| key | string | 是 | 要设置的数据的键,密钥可以自定义。 |
| value | string | 是 | 要设置的数据的值。 |
......@@ -601,7 +601,7 @@ setAssociatedData(name: string, key: string, value: string): Promise&lt;void&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------------------- |
| ----- | ------ | ---- | ----------------- |
| name | string | 是 | 应用帐号名称。 |
| key | string | 是 | 要设置的数据的键,密钥可以自定义。 |
| value | string | 是 | 要设置的数据的值。 |
......@@ -609,7 +609,7 @@ setAssociatedData(name: string, key: string, value: string): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| :------------------ | :-------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -634,7 +634,7 @@ getAccountCredential(name: string, credentialType: string, callback: AsyncCallba
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | --------------------------- | ---- | ---------------------------- |
| -------------- | --------------------------- | ---- | -------------- |
| name | string | 是 | 应用帐号名称。 |
| credentialType | string | 是 | 获取此应用帐号的凭据的类型。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 获取此应用帐号的凭据的回调。 |
......@@ -660,14 +660,14 @@ getAccountCredential(name: string, credentialType: string): Promise&lt;string&gt
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------ | ---- | -------------------- |
| -------------- | ------ | ---- | ---------- |
| name | string | 是 | 应用帐号名称。 |
| credentialType | string | 是 | 要获取的凭据的类型。 |
**返回值:**
| 类型 | 说明 |
| :-------------------- | :---------------------------------- |
| :-------------------- | :-------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -692,7 +692,7 @@ getAccountExtraInfo(name: string, callback: AsyncCallback&lt;string&gt;): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------ |
| -------- | --------------------------- | ---- | --------------- |
| name | string | 是 | 应用帐号名称。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 获取此应用帐号的额外信息回调。 |
......@@ -717,13 +717,13 @@ getAccountExtraInfo(name: string): Promise&lt;string&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------- |
| ---- | ------ | ---- | ------- |
| name | string | 是 | 应用帐号名称。 |
**返回值:**
| 类型 | 说明 |
| :-------------------- | :---------------------------------- |
| :-------------------- | :-------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -748,7 +748,7 @@ getAssociatedData(name: string, key: string, callback: AsyncCallback&lt;string&g
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------------- |
| -------- | --------------------------- | ---- | ----------------- |
| name | string | 是 | 应用帐号名称。 |
| key | string | 是 | 要获取的数据的键。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 获取与此应用帐号关联的数据的回调。 |
......@@ -774,14 +774,14 @@ getAssociatedData(name: string, key: string): Promise&lt;string&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------ |
| ---- | ------ | ---- | --------- |
| name | string | 是 | 应用帐号名称。 |
| key | string | 是 | 要获取的数据的键。 |
**返回值:**
| 类型 | 说明 |
| :-------------------- | :---------------------------------- |
| :-------------------- | :-------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -808,7 +808,7 @@ getAllAccessibleAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | ------------------ |
| -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt; | 是 | 应用帐号信息列表。 |
**示例:**
......@@ -834,7 +834,7 @@ getAllAccessibleAccounts(): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;
**参数:**
| 类型 | 说明 |
| ------------------------------------------ | ----------------------------------- |
| ---------------------------------------- | --------------------- |
| Promise&lt;Array&lt;AppAccountInfo&gt;&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -861,7 +861,7 @@ getAllAccounts(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | ------------------ |
| -------- | ---------------------------------------- | ---- | --------- |
| owner | string | 是 | 应用包名称。 |
| callback | AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt; | 是 | 应用帐号信息列表。 |
......@@ -889,13 +889,13 @@ getAllAccounts(owner: string): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------ |
| ----- | ------ | ---- | ------ |
| owner | string | 是 | 应用包名称。 |
**参数:**
| 类型 | 说明 |
| ------------------------------------------ | ----------------------------------- |
| ---------------------------------------- | --------------------- |
| Promise&lt;Array&lt;AppAccountInfo&gt;&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -921,7 +921,7 @@ on(type: 'change', owners: Array&lt;string&gt;, callback: Callback&lt;Array&lt;A
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
| -------- | ---------------------------------------- | ---- | ------------------------------ |
| type | 'change' | 是 | 关于帐号更改事件,当帐号所有者更新帐号时,订阅者将收到通知。 |
| owners | Array&lt;string&gt; | 是 | 指示帐号的所有者。 |
| callback | Callback&lt;Array&lt;AppAccountInfo&gt;&gt; | 是 | 订阅指定帐号所有者的帐号变更事件的回调。 |
......@@ -952,7 +952,7 @@ off(type: 'change', callback?: Callback<Array\<AppAccountInfo>>): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | ---- | ------------------------ |
| -------- | -------------------------------- | ---- | ------------ |
| type | 'change' | 是 | 关于帐号更改事件。 |
| callback | Callback<Array\<AppAccountInfo>> | 否 | 取消订阅帐号事件的回调。 |
......@@ -985,7 +985,7 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------------ |
| -------- | --------------------- | ---- | --------------- |
| name | string | 是 | 要鉴权的应用帐号名称。 |
| owner | string | 是 | 要鉴权的应用帐号所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
......@@ -1027,11 +1027,11 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------- |
| -------- | --------------------------- | ---- | ----------- |
| name | string | 是 | 应用帐号的名称。 |
| owner | string | 是 | 应用帐号的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
| callback |AsyncCallback&lt;string&gt; | 是 | 查询结果的回调。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 查询结果的回调。 |
**示例:**
......@@ -1054,7 +1054,7 @@ getOAuthToken(name: string, owner: string, authType: string): Promise&lt;string&
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------------- |
| -------- | ------ | ---- | ----------- |
| name | string | 是 | 应用帐号的名称。 |
| owner | string | 是 | 应用帐号的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
......@@ -1062,7 +1062,7 @@ getOAuthToken(name: string, owner: string, authType: string): Promise&lt;string&
**参数:**
| 类型 | 说明 |
| --------------------- | ----------------------------------- |
| --------------------- | --------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -1087,7 +1087,7 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------- |
| -------- | ------------------------- | ---- | -------- |
| name | string | 是 | 应用帐号的名称。 |
| authType | string | 是 | 鉴权类型。 |
| token | string | 是 | OAuth令牌。 |
......@@ -1113,7 +1113,7 @@ setOAuthToken(name: string, authType: string, token: string): Promise&lt;void&gt
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------- |
| -------- | ------ | ---- | -------- |
| name | string | 是 | 应用帐号的名称。 |
| authType | string | 是 | 鉴权类型。 |
| token | string | 是 | OAuth令牌。 |
......@@ -1121,7 +1121,7 @@ setOAuthToken(name: string, authType: string, token: string): Promise&lt;void&gt
**参数:**
| 类型 | 说明 |
| ------------------- | ----------------------------------- |
| ------------------- | --------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -1146,7 +1146,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------- |
| -------- | ------------------------- | ---- | ------------ |
| name | string | 是 | 应用帐号的名称。 |
| owner | string | 是 | 应用帐号的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
......@@ -1173,7 +1173,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string):
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------------- |
| -------- | ------ | ---- | ------------ |
| name | string | 是 | 应用帐号的名称。 |
| owner | string | 是 | 应用帐号的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
......@@ -1182,7 +1182,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string):
**参数:**
| 类型 | 说明 |
| ------------------- | ----------------------------------- |
| ------------------- | --------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -1207,7 +1207,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ----------------------------------------- |
| ---------- | ------------------------- | ---- | ------------------------- |
| name | string | 是 | 应用帐号的名称。 |
| authType | string | 是 | 鉴权类型。 |
| bundleName | string | 是 | 被设置可见性的应用包名。 |
......@@ -1234,7 +1234,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------- | ---- | ------------------------ |
| ---------- | ------- | ---- | ------------ |
| name | string | 是 | 应用帐号的名称。 |
| authType | string | 是 | 鉴权类型。 |
| bundleName | string | 是 | 被设置可见性的应用包名。 |
......@@ -1243,7 +1243,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
**参数:**
| 类型 | 说明 |
| ------------------- | ----------------------------------- |
| ------------------- | --------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -1268,7 +1268,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------- | ---- | ---------------------- |
| ---------- | ---------------------------- | ---- | ----------- |
| name | string | 是 | 应用帐号的名称。 |
| authType | string | 是 | 鉴权类型。 |
| bundleName | string | 是 | 检查可见性的应用包名。 |
......@@ -1295,7 +1295,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | -------------------------- |
| ---------- | ------ | ---- | ------------- |
| name | string | 是 | 应用帐号的名称。 |
| authType | string | 是 | 鉴权类型。 |
| bundleName | string | 是 | 用于检查可见性的应用包名。 |
......@@ -1303,7 +1303,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P
**参数:**
| 类型 | 说明 |
| ---------------------- | ----------------------------------- |
| ---------------------- | --------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -1328,7 +1328,7 @@ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback&lt;Array&
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ---------------------- |
| -------- | ---------------------------------------- | ---- | ----------- |
| name | string | 是 | 应用帐号的名称。 |
| owner | string | 是 | 应用帐号的所有者包名。 |
| callback | AsyncCallback&lt;Array&lt; [OAuthTokenInfo](#oauthtokeninfo8)&gt;&gt; | 是 | 查询结果的回调。 |
......@@ -1354,14 +1354,14 @@ getAllOAuthTokens(name: string, owner: string): Promise&lt;Array&lt;OAuthTokenIn
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------- |
| ----- | ------ | ---- | ----------- |
| name | string | 是 | 应用帐号的名称。 |
| owner | string | 是 | 应用帐号的所有者包名。 |
**参数:**
| 类型 | 说明 |
| ------------------------------------------ | ----------------------------------- |
| ---------------------------------------- | --------------------- |
| Promise&lt;Array&lt; [OAuthTokenInfo](#oauthtokeninfo8)&gt;&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -1386,7 +1386,7 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback&lt;Array&lt
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ----------------------------------------- |
| -------- | ---------------------------------------- | ---- | ----------------------- |
| name | string | 是 | 应用帐号的名称。 |
| authType | string | 是 | 应用帐号的鉴权类型的OAuth令牌的授权列表。 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 查询结果的回调。 |
......@@ -1412,14 +1412,14 @@ getOAuthList(name: string, authType: string): Promise&lt;Array&lt;string&gt;&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ----------------------------------------- |
| -------- | ------ | ---- | ----------------------- |
| name | string | 是 | 应用帐号的名称。 |
| authType | string | 是 | 应用帐号的鉴权类型的OAuth令牌的授权列表。 |
**参数:**
| 类型 | 说明 |
| ---------------------------------- | ----------------------------------- |
| ---------------------------------- | --------------------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -1444,7 +1444,7 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;Authentic
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------------------------ | ---- | ---------------- |
| --------- | ---------------------------------------- | ---- | -------- |
| sessionId | string | 是 | 鉴权会话的标识。 |
| callback | AsyncCallback&lt;AuthenticatorCallback&gt; | 是 | 查询结果的回调。 |
......@@ -1480,13 +1480,13 @@ getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ---------------- |
| --------- | ------ | ---- | -------- |
| sessionId | string | 是 | 鉴权会话的标识。 |
**参数:**
| 类型 | 说明 |
| ------------------------------------ | ----------------------------------- |
| ------------------------------------ | --------------------- |
| Promise&lt;AuthenticatorCallback&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -1520,7 +1520,7 @@ getAuthenticatorInfo(owner: string, callback: AsyncCallback&lt;AuthenticatorInfo
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ---------------------- |
| -------- | -------------------------------------- | ---- | ----------- |
| owner | string | 是 | 应用帐号的所有者包名。 |
| callback | AsyncCallback&lt;AuthenticatorInfo&gt; | 是 | 查询结果的回调。 |
......@@ -1545,13 +1545,13 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------- |
| ----- | ------ | ---- | ----------- |
| owner | string | 是 | 应用帐号的所有者包名。 |
**参数:**
| 类型 | 说明 |
| -------------------------------- | ----------------------------------- |
| -------------------------------- | --------------------- |
| Promise&lt;AuthenticatorInfo&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
......@@ -1572,7 +1572,7 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------- |
| ----- | ------ | ---- | ----------- |
| owner | string | 是 | 应用帐号的所有者包名。 |
| name | string | 是 | 应用帐号的名称。 |
......@@ -1583,7 +1583,7 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------- |
| -------- | ------ | ---- | -------- |
| authType | string | 是 | 令牌的鉴权类型。 |
| token | string | 是 | 令牌的取值。 |
......@@ -1594,7 +1594,7 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | -------------------- |
| ------- | ------ | ---- | ---------- |
| owner | string | 是 | 认证器的所有者包名。 |
| iconId | string | 是 | 认证器的图标标识。 |
| labelId | string | 是 | 认证器的标签标识。 |
......@@ -1606,7 +1606,7 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。
| 名称 | 默认值 | 说明 |
| ----------------------------- | ---------------------- | -------------------------- |
| ----------------------------- | ---------------------- | ------------- |
| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | 表示操作,隐式添加帐号。 |
| ACTION_AUTHENTICATE | "authenticate" | 表示操作,鉴权。 |
| KEY_NAME | "name" | 表示键名,应用帐号名称。 |
......@@ -1626,7 +1626,7 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。
| 名称 | 默认值 | 说明 |
| ----------------------------------- | ------ | ------------------------ |
| ----------------------------------- | ----- | ------------ |
| SUCCESS | 0 | 表示操作成功。 |
| ERROR_ACCOUNT_NOT_EXIST | 10001 | 表示应用帐号不存在。 |
| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | 表示应用帐号服务异常。 |
......@@ -1661,7 +1661,7 @@ onResult: (code: number, result: {[key: string]: any}) =&gt; void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | -------------------- | ---- | ------------ |
| ------ | -------------------- | ---- | ------ |
| code | number | 是 | 鉴权结果码。 |
| result | {[key: string]: any} | 是 | 鉴权结果。 |
......@@ -1691,7 +1691,7 @@ onRequestRedirected: (request: Want) =&gt; void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ---- | ---- | -------------------- |
| ------- | ---- | ---- | ---------- |
| request | Want | 是 | 用于跳转的请求信息。 |
**示例:**
......@@ -1728,7 +1728,7 @@ addAccountImplicitly(authType: string, callerBundleName: string, options: {[key:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------------- | --------------------- | ---- | ------------------------------ |
| ---------------- | --------------------- | ---- | --------------- |
| authType | string | 是 | 应用帐号的鉴权类型。 |
| callerBundleName | string | 是 | 鉴权请求方的包名。 |
| options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 |
......@@ -1744,7 +1744,7 @@ authenticate(name: string, authType: string, callerBundleName: string, options:
**参数:**
| 接口名 | 类型 | 必填 | 说明 |
| ---------------- | --------------------- | ---- | ------------------------------ |
| ---------------- | --------------------- | ---- | --------------- |
| name | string | 是 | 应用帐号的名称。 |
| authType | string | 是 | 应用帐号的鉴权类型。 |
| callerBundleName | string | 是 | 鉴权请求方的包名。 |
......
......@@ -224,7 +224,7 @@ var audioCapturerOptions = {
}
var audioCapturer;
audio.createAudioRenderer(audioCapturerOptions).then((data) => {
audio.createAudioCapturer(audioCapturerOptions).then((data) => {
audioCapturer = data;
console.info('AudioCapturer Created : Success : Stream Type: SUCCESS');
}).catch((err) => {
......@@ -1314,7 +1314,7 @@ setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCa
**示例:**
```
audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err) => {
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => {
if (err) {
console.error('Failed to set the active status of the device. ${err.message}');
return;
......@@ -1348,7 +1348,7 @@ setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise&lt;void&
```
audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(() => {
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => {
console.log('Promise returned to indicate that the device is set to the active status.');
});
```
......@@ -1371,7 +1371,7 @@ isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback&lt;boolean&
**示例:**
```
audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => {
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => {
if (err) {
console.error('Failed to obtain the active status of the device. ${err.message}');
return;
......@@ -1404,7 +1404,7 @@ isDeviceActive(deviceType: ActiveDeviceType): Promise&lt;boolean&gt;
**示例:**
```
audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) => {
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) => {
console.log('Promise returned to indicate that the active status of the device is obtained.' + value);
});
```
......@@ -1638,7 +1638,7 @@ var interAudioInterrupt = {
contentType:0,
pauseWhenDucked:true
};
this.audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => {
audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => {
if (InterruptAction.actionType === 0) {
console.log("An event to gain the audio focus starts.");
console.log("Focus gain event:" + JSON.stringify(InterruptAction));
......@@ -1674,7 +1674,7 @@ var interAudioInterrupt = {
contentType:0,
pauseWhenDucked:true
};
this.audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => {
audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => {
if (InterruptAction.actionType === 0) {
console.log("An event to release the audio focus starts.");
console.log("Focus release event:" + JSON.stringify(InterruptAction));
......@@ -1736,7 +1736,7 @@ setAudioScene\(scene: AudioScene\): Promise<void\>
**示例:**
```
audioManager.setAudioScene(audio.AudioSceneMode.AUDIO_SCENE_PHONE_CALL).then(() => {
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => {
console.log('Promise returned to indicate a successful setting of the audio scene mode.');
}).catch ((err) => {
console.log('Failed to set the audio scene mode');
......@@ -1895,6 +1895,7 @@ getRendererInfo(): Promise<AudioRendererInfo\>
**示例:**
```
var resultFlag = true;
audioRenderer.getRendererInfo().then((rendererInfo) => {
console.log('Renderer GetRendererInfo:');
console.log('Renderer content:' + rendererInfo.content);
......@@ -2341,13 +2342,11 @@ getBufferSize(callback: AsyncCallback\<number>): void
**示例:**
```
audioRenderer.getBufferSize((err, bufferSize) => {
var bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => {
if (err) {
console.error('getBufferSize error');
}
});
let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf);
```
### getBufferSize<sup>8+</sup>
......@@ -2367,11 +2366,12 @@ getBufferSize(): Promise\<number>
**示例:**
```
audioRenderer.getBufferSize().then((bufferSize) => {
let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf);
var bufferSize;
await audioRenderer.getBufferSize().then(async function (data) => {
console.info('AudioFrameworkRenderLog: getBufferSize :SUCCESS '+data);
bufferSize=data;
}).catch((err) => {
console.log('ERROR: '+err.message);
console.info('AudioFrameworkRenderLog: getBufferSize :ERROR : '+err.message);
});
```
......@@ -2496,7 +2496,9 @@ on(type: 'interrupt', callback: Callback\<InterruptEvent>): void
**示例:**
```
audioRenderer.on('interrupt', (interruptEvent) => {
var isPlay;
var started;
audioRenderer.on('interrupt', async(interruptEvent) => {
if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
......@@ -2512,11 +2514,30 @@ audioRenderer.on('interrupt', (interruptEvent) => {
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_RESUME:
console.log('Resume force paused renderer or ignore');
startRenderer();
await audioRenderer.start().then(async function () {
console.info('AudioInterruptMusic: renderInstant started :SUCCESS ');
started = true;
}).catch((err) => {
console.info('AudioInterruptMusic: renderInstant start :ERROR : '+err.message);
started = false;
});
if (started) {
isPlay = true;
console.info('AudioInterruptMusic Renderer started : isPlay : '+isPlay);
} else {
console.error('AudioInterruptMusic Renderer start failed');
}
break;
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
console.log('Choose to pause or ignore');
pauseRenderer();
if (isPlay == true) {
isPlay == false;
console.info('AudioInterruptMusic: Media PAUSE : TRUE');
}
else {
isPlay = true;
console.info('AudioInterruptMusic: Media PLAY : TRUE');
}
break;
}
}
......@@ -2885,7 +2906,7 @@ stop(): Promise<void\>
audioCapturer.stop().then(() => {
console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------');
console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS');
if ((audioCapturer.state == audioCapturer.AudioState.STATE_STOPPED)){
if ((audioCapturer.state == audio.AudioState.STATE_STOPPED)){
stateFlag=true;
console.info('AudioFrameworkRecLog: resultFlag : '+stateFlag);
}
......@@ -2945,8 +2966,6 @@ audioCapturer.release().then(() => {
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapturer.state);
stateFlag=true;
console.info('AudioFrameworkRecLog: stateFlag : '+stateFlag);
expect(stateFlag).assertTrue();
done();
}).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message);
stateFlag=false
......@@ -3108,15 +3127,12 @@ getBufferSize(): Promise<number\>
**示例:**
```
audioCapturer.getBufferSize().then((bufferSize) => {
if (!err) {
console.log('BufferSize : ' + bufferSize);
audioCapturer.read(bufferSize, true).then((buffer) => {
await audioCapturer.getBufferSize().then(async function (bufferSize) {
console.info('AudioFrameworkRecordLog: getBufferSize :SUCCESS '+ bufferSize);
var buffer = await audioCapturer.read(bufferSize, true);
console.info('Buffer read is ' + buffer );
}).catch((err) => {
console.info('ERROR : '+err.message);
});
}
console.info('AudioFrameworkRecordLog: getBufferSize :ERROR : '+err.message);
});
```
......
# 配置策略
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口均为系统接口,三方应用不支持调用。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 本模块接口均为系统接口,三方应用不支持调用。
配置策略提供按预先定义的定制配置层级获取对应定制配置目录和文件路径的能力。
## 导入模块
```
```js
import configPolicy from '@ohos.configPolicy';
```
......@@ -22,18 +24,18 @@ getOneCfgFile(relPath: string, callback: AsyncCallback&lt;string&gt;): void
**系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| relPath | string | 是 | 配置文件名 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步回调,用于返回最高优先级配置文件的路径 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | --------------------- |
| relPath | string | 是 | 配置文件名 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步回调,用于返回最高优先级配置文件的路径 |
**示例:**
```
```js
configPolicy.getOneCfgFile('config.xml', (error, value) => {
if (error == undefined) {
console.log(value);
console.log("value is " + value);
} else {
console.log(error);
console.log("error occurs "+ error);
}
});
```
......@@ -48,19 +50,19 @@ getOneCfgFile(relPath: string): Promise&lt;string&gt;
**系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| relPath | string | 是 | 配置文件名 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ----- |
| relPath | string | 是 | 配置文件名 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;string&gt; | 最高优先级配置文件的路径 |
| 类型 | 说明 |
| --------------------- | ------------ |
| Promise&lt;string&gt; | 最高优先级配置文件的路径 |
**示例:**
```
```js
configPolicy.getOneCfgFile('config.xml').then(value => {
console.log(value);
console.log("value is " + value);
}).catch(error => {
console.log("getOneCfgFile promise " + error);
});
......@@ -77,18 +79,18 @@ getCfgFiles(relPath: string, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;)
**系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| relPath | string | 是 | 配置文件名 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 异步回调,用于返回文件列表 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------- |
| relPath | string | 是 | 配置文件名 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 异步回调,用于返回文件列表 |
**示例:**
```
```js
configPolicy.getCfgFiles('config.xml', (error, value) => {
if (error == undefined) {
console.log(value);
console.log("value is " + value);
} else {
console.log(error);
console.log("error occurs "+ error);
}
});
```
......@@ -103,19 +105,19 @@ getCfgFiles(relPath: string): Promise&lt;Array&lt;string&gt;&gt;
**系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| relPath | string | 是 | 配置文件名 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ----- |
| relPath | string | 是 | 配置文件名 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;Array&lt;string&gt;&gt; | 文件列表 |
| 类型 | 说明 |
| ---------------------------------- | ---- |
| Promise&lt;Array&lt;string&gt;&gt; | 文件列表 |
**示例:**
```
```js
configPolicy.getCfgFiles('config.xml').then(value => {
console.log(value);
console.log("value is " + value);
}).catch(error => {
console.log("getCfgFiles promise " + error);
});
......@@ -131,17 +133,17 @@ getCfgDirList(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
**系统能力**:SystemCapability.Customization.ConfigPolicy
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 异步回调,用于返回配置层级目录列表 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ----------------- |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 异步回调,用于返回配置层级目录列表 |
**示例:**
```
```js
configPolicy.getCfgDirList((error, value) => {
if (error == undefined) {
console.log(value);
console.log("value is " + value);
} else {
console.log(error);
console.log("error occurs "+ error);
}
});
```
......@@ -156,14 +158,14 @@ getCfgDirList(): Promise&lt;Array&lt;string&gt;&gt;
**系统能力**:SystemCapability.Customization.ConfigPolicy
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;Array&lt;string&gt;&gt; | 配置层级目录列表 |
| 类型 | 说明 |
| ---------------------------------- | -------- |
| Promise&lt;Array&lt;string&gt;&gt; | 配置层级目录列表 |
**示例:**
```
```js
configPolicy.getCfgDirList().then(value => {
console.log(value);
console.log("value is " + value);
}).catch(error => {
console.log("getCfgDirList promise " + error);
});
......
......@@ -12,6 +12,7 @@ import deviceInfo from '@ohos.deviceInfo'
## 属性
**系统能力**:以下各项对应的系统能力均为SystemCapability.Startup.SysInfo。
**权限**:以下各项所需要的权限有所不同,详见下表。
| 名称 | 参数类型 | 可读 | 可写 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
......@@ -24,7 +25,7 @@ import deviceInfo from '@ohos.deviceInfo'
| softwareModel | string | 是 | 否 | 内部软件子型号。 |
| hardwareModel | string | 是 | 否 | 硬件版本号。 |
| hardwareProfile | string | 是 | 否 | 硬件Profile。 |
| serial | string | 是 | 否 | 设备序列号。 |
| serial | string | 是 | 否 | 设备序列号。<br/>**需要权限**:ohos.permission.sec.ACCESS_UDID,该权限为系统权限 |
| bootloaderVersion | string | 是 | 否 | Bootloader版本号。 |
| abiList | string | 是 | 否 | 应用二进制接口(Abi)列表。 |
| securityPatchTag | string | 是 | 否 | 安全补丁级别。 |
......@@ -44,4 +45,4 @@ import deviceInfo from '@ohos.deviceInfo'
| buildHost | string | 是 | 否 | 构建主机。 |
| buildTime | string | 是 | 否 | 构建时间。 |
| buildRootHash | string | 是 | 否 | 构建版本Hash。 |
| udid<sup>7+</sup> | string | 是 | 否 | 设备Udid。 |
| udid<sup>7+</sup> | string | 是 | 否 | 设备Udid。<br/>**需要权限**:ohos.permission.sec.ACCESS_UDID,该权限为系统权限|
# 企业设备管理
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
```js
import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager';
```
......@@ -26,7 +27,7 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------------- | ----------------------------------- | ---- | ------------------ |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 |
| type | [AdminType](#AdminType) | 是 | 激活的设备管理员类型 |
......@@ -34,7 +35,7 @@ SystemCapability.Customation.EnterpriseDeviceManager
**示例**
```
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
......@@ -48,7 +49,7 @@ enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDevice
console.log("error occurs" + error);
return;
}
console.log(result);
console.log("result is " + result);
});
```
......@@ -67,7 +68,7 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ---------------------------------------------- | ---- | ------------------------ |
| -------------- | ----------------------------------- | ---- | ------------ |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 |
| type | [AdminType](#AdminType) | 是 | 激活的设备管理员类型 |
......@@ -75,12 +76,12 @@ SystemCapability.Customation.EnterpriseDeviceManager
**返回值:**
| 类型 | 说明 |
| ----------------- | --------------------------- |
| ----------------- | ----------------- |
| Promise\<boolean> | Promise形式返回是否激活成功 |
**示例**
```
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
......@@ -91,7 +92,7 @@ let enterpriseInfo = {
}
enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL)
.then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -112,23 +113,23 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------------- | ---- | ------------------------------ |
| -------- | ----------------------------------- | ---- | ------------------- |
| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管理员应用 |
| callback | AsyncCallback\<boolean> | 是 | callback方式返回是否去激活成功 |
**示例**
```
```js
let wantTemp = {
bundleName: elementName.bundleName,
abilityName: elementName.abilityName,
bundleName: "bundleName",
abilityName: "abilityName",
};
enterpriseDeviceManager.deactivateAdmin(wantTemp, (error, result) => {
if (error != null) {
console.log("error occurs" + error);
return;
}
console.log(result);
console.log("result is " + result);
});
```
......@@ -149,24 +150,24 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------------------------- | ---- | ------------------ |
| ----- | ----------------------------------- | ---- | --------- |
| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管理员应用 |
**返回值:**
| 类型 | 说明 |
| ----------------- | --------------------------- |
| ----------------- | ----------------- |
| Promise\<boolean> | Promise形式返回是否激活成功 |
**示例**
```
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
enterpriseDeviceManager.deactivateAdmin(wantTemp).then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -184,20 +185,20 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ----------------------- | ---- | ------------------------------ |
| ---------- | ----------------------- | ---- | ------------------- |
| bundleName | String | 是 | 超级设备管理员应用的包名 |
| callback | AsyncCallback\<boolean> | 是 | callback方式返回是否去激活成功 |
**示例**
```
```js
let bundleName = "com.example.myapplication";
enterpriseDeviceManager.deactivateSuperAdmin(bundleName, (error, result) => {
if (error != null) {
console.log("error occurs" + error);
return;
}
console.log(result);
console.log("result is " + result);
});
```
......@@ -213,21 +214,21 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ------------------------ |
| ---------- | ------ | ---- | ------------ |
| bundleName | String | 是 | 超级设备管理员应用的包名 |
**返回值:**
| 类型 | 说明 |
| ----------------- | --------------------------- |
| ----------------- | ----------------- |
| Promise\<boolean> | Promise形式返回是否激活成功 |
**示例**
```
```js
let bundleName = "com.example.myapplication";
enterpriseDeviceManager.deactivateSuperAdmin(bundleName).then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -245,23 +246,23 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------------- | ---- | -------------------------------- |
| -------- | ----------------------------------- | ---- | -------------------- |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
| callback | AsyncCallback\<boolean> | 是 | callback方式返回是否处于激活状态 |
**示例**
```
```js
let wantTemp = {
bundleName: elementName.bundleName,
abilityName: elementName.abilityName,
bundleName: "bundleName",
abilityName: "abilityName",
};
enterpriseDeviceManager.isAdminAppActive(wantTemp, (error, result) => {
if (error != null) {
console.log("error occurs" + error);
return;
}
console.log(result);
console.log("result is " + result);
});
```
......@@ -279,24 +280,24 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------------------------- | ---- | -------------- |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
**返回值:**
| 类型 | 说明 |
| ----------------- | ------------------------------- |
| ----------------- | ------------------- |
| Promise\<boolean> | Promise形式返回是否处于激活状态 |
**示例**
```
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
enterpriseDeviceManager.isAdminAppActive(wantTemp).then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -314,20 +315,20 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ----------------------- | ---- | -------------------------------- |
| ---------- | ----------------------- | ---- | -------------------- |
| bundleName | String | 是 | 设备管理员应用 |
| callback | AsyncCallback\<boolean> | 是 | callback方式返回是否处于激活状态 |
**示例**
```
```js
let bundleName = "com.example.myapplication";
enterpriseDeviceManager.isSuperAdmin(bundleName, (error, result) => {
if (error != null) {
console.log("error occurs" + error);
return;
}
console.log(result);
console.log("result is " + result);
});
```
......@@ -345,21 +346,21 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ------------------ |
| ---------- | ------ | ---- | --------- |
| bundleName | String | 是 | 超级设备管理员应用 |
**返回值:**
| 类型 | 说明 |
| ----------------- | ------------------------------- |
| ----------------- | ------------------- |
| Promise\<boolean> | Promise形式返回是否处于激活状态 |
**示例**
```
```js
let bundleName = "com.example.myapplication";
enterpriseDeviceManager.isSuperAdmin(bundleName).then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -377,12 +378,12 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | --------------------------------------- | ---- | ----------------------------------- |
| callback | AsyncCallback<DeviceSettingsManager&gt; | 是 | callback方式返回DeviceSettingsManager对象 |
**示例:**
```
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
......@@ -415,12 +416,12 @@ SystemCapability.Customation.EnterpriseDeviceManager
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| ------------------------------------ | ---------------------------------- |
| Promise&lt;DeviceSettingsManager&gt; | Promise方式返回DeviceSettingsManager对象 |
**示例:**
```
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
......@@ -448,14 +449,14 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ---------------------------------------------- | ---- | ------------------------------------ |
| -------------- | ----------------------------------- | ---- | ---------------------- |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 |
| callback | AsyncCallback\<boolean&gt; | 是 | callback方式返回是否设置企业信息成功 |
**示例:**
```
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
......@@ -466,7 +467,7 @@ let enterpriseInfo = {
}
enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo)
.then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -485,19 +486,19 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ---------------------------------------------- | ---- | ------------------------ |
| -------------- | ----------------------------------- | ---- | ------------ |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管理员应用的企业信息 |
**返回值:**
| 类型 | 说明 |
| ------------------ | ----------------------------------- |
| ------------------ | --------------------- |
| Promise\<boolean>; | Promise方式返回是否设置企业信息成功 |
**示例:**
```
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
......@@ -508,7 +509,7 @@ let enterpriseInfo = {
}
enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo)
.then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -526,13 +527,13 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------ | ---- | ---------------------------------------- |
| -------- | ---------------------------------------- | ---- | ------------------------ |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
| callback | AsyncCallback&lt;[EnterpriseInfo](#EnterpriseInfo)&gt; | 是 | callback方式返回设备管理员应用的企业信息 |
**示例:**
```
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
......@@ -560,18 +561,18 @@ SystemCapability.Customation.EnterpriseDeviceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------------------------- | ---- | -------------- |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | 是 | 设备管理员应用 |
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------ | ------------------------------------------- |
| ---------------------------------------- | ------------------------- |
| Promise&lt;[EnterpriseInfo](#EnterpriseInfo)&gt; | Promise方式返回设备管理员应用的企业信息对象 |
**示例:**
```
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
......@@ -591,7 +592,7 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => {
**系统能力:**
以下各项对应系统能力均为SystemCapability.Customation.EnterpriseDeviceManager
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ----------- | -------- | ------ | ---- | ---------------------------------- |
| ----------- | ---- | ------ | ---- | ----------------- |
| name | 只读 | string | 是 | 表示设备管理员应用所属企业的名称。 |
| description | 只读 | string | 是 | 表示设备管理员应用所属企业的描述。 |
......@@ -603,6 +604,6 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => {
**系统能力:**
以下各项对应系统能力均为SystemCapability.Customation.EnterpriseDeviceManager
| 名称 | 默认值 | 说明 |
| -------- | -------- | -------- |
| ----------------- | ---- | ----- |
| ADMIN_TYPE_NORMAL | 0x00 | 普通管理员 |
| ADMIN_TYPE_SUPER | 0x01 | 超级管理员 |
......@@ -20,10 +20,8 @@ import fileio from '@ohos.fileio';
## 使用说明
使用该功能模块对文件/目录进行操作前,需要先获取其应用沙箱路径,获取方式及其接口用法请参考:[Context模块的接口getOrCreateLocalDir](js-apis-Context.md)
“文件/目录应用沙箱路径”=“应用目录路径”+“文件/目录名”
使用该功能模块对文件/目录进行操作前,需要先获取其应用沙箱绝对路径,“文件/目录应用沙箱路径”=“应用目录路径”+“文件/目录名”。
应用目录路径dir的获取方式及对应的接口用法请参考:[Context模块的接口getOrCreateLocalDir](js-apis-Context.md)
通过上述接口获取到应用目录路径dir,文件名为“xxx.txt”,文件所在应用沙箱路径为:
```js
......@@ -43,7 +41,7 @@ let fd = fileio.openSync(path);
stat(path: string): Promise&lt;Stat&gt;
以异步方法获取文件信息,使用promise形式返回结果
获取文件信息,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -57,12 +55,12 @@ stat(path: string): Promise&lt;Stat&gt;
| 类型 | 说明 |
| ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | 表示文件的具体信息。 |
| Promise&lt;[Stat](#stat)&gt; | Promise对象。返回文件的具体信息。 |
**示例:**
```js
fileio.stat(path).then(function(stat){
console.info("getFileInfo successfully:"+ JSON.stringify(stat));
console.info("getFileInfo succeed:"+ JSON.stringify(stat));
}).catch(function(err){
console.info("getFileInfo failed with error:"+ err);
});
......@@ -73,7 +71,7 @@ stat(path: string): Promise&lt;Stat&gt;
stat(path:string, callback:AsyncCallback&lt;Stat&gt;): void
以异步方法获取文件信息,使用callback形式返回结果
获取文件信息,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -121,7 +119,7 @@ statSync(path:string): Stat
opendir(path: string): Promise&lt;Dir&gt;
以异步方法打开文件目录,使用promise形式返回结果
打开文件目录,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -133,12 +131,12 @@ opendir(path: string): Promise&lt;Dir&gt;
**返回值:**
| 类型 | 说明 |
| -------------------------- | -------- |
| Promise&lt;[Dir](#dir)&gt; | 返回Dir对象。 |
| Promise&lt;[Dir](#dir)&gt; | Promise对象。返回Dir对象。 |
**示例:**
```js
fileio.opendir(path).then(function(dir){
console.info("opendir successfully:"+ JSON.stringify(dir));
console.info("opendir succeed:"+ JSON.stringify(dir));
}).catch(function(err){
console.info("opendir failed with error:"+ err);
});
......@@ -149,7 +147,7 @@ opendir(path: string): Promise&lt;Dir&gt;
opendir(path: string, callback: AsyncCallback&lt;Dir&gt;): void
以异步方法打开文件目录,使用callback形式返回结果
打开文件目录,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -201,7 +199,7 @@ opendirSync(path: string): Dir
access(path: string, mode?: number): Promise&lt;void&gt;
以异步方法检查当前进程是否可访问某文件,使用promise形式返回结果
检查当前进程是否可访问某文件,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -215,12 +213,12 @@ access(path: string, mode?: number): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.access(path).then(function() {
console.info("access successfully");
console.info("access succeed");
}).catch(function(err){
console.info("access failed with error:"+ err);
});
......@@ -231,7 +229,7 @@ access(path: string, mode?: number): Promise&lt;void&gt;
access(path: string, mode: number, callback: AsyncCallback&lt;void&gt;): void
以异步方法检查当前进程是否可访问某文件,使用callback形式返回结果
检查当前进程是否可访问某文件,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -278,7 +276,7 @@ accessSync(path: string, mode?: number): void
close(fd: number):Promise&lt;void&gt;
以异步方法关闭文件,使用promise形式返回结果
关闭文件,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -290,13 +288,13 @@ close(fd: number):Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
let fd = fileio.openSync(path);
fileio.close(fd).then(function(){
console.info("close file successfully");
console.info("close file succeed");
}).catch(function(err){
console.info("close file failed with error:"+ err);
});
......@@ -307,7 +305,7 @@ close(fd: number):Promise&lt;void&gt;
close(fd: number, callback:AsyncCallback&lt;void&gt;): void
以异步方法关闭文件,使用callback形式返回结果
关闭文件,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -349,19 +347,19 @@ closeSync(fd: number): void
close(): Promise&lt;void&gt;
以异步方法关闭文件流,使用promise形式返回结果
关闭文件流,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.close().then(function(){
console.info("close file stream successfully");
console.info("close file stream succeed");
}).catch(function(err){
console.info("close file stream failed with error:"+ err);
});
......@@ -372,7 +370,7 @@ close(): Promise&lt;void&gt;
close(callback: AsyncCallback&lt;void&gt;): void
以异步方法关闭文件流,使用callback形式返回结果
关闭文件流,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -393,7 +391,7 @@ close(callback: AsyncCallback&lt;void&gt;): void
copyFile(src:string | number, dest:string | number, mode?:number):Promise&lt;void&gt;
以异步方法复制文件,使用promise形式返回结果
复制文件,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -407,12 +405,12 @@ copyFile(src:string | number, dest:string | number, mode?:number):Promise&lt;voi
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.copyFile(src, dest).then(function(){
console.info("copyFile successfully");
console.info("copyFile succeed");
}).catch(function(err){
console.info("copyFile failed with error:"+ err);
});
......@@ -423,7 +421,7 @@ copyFile(src:string | number, dest:string | number, mode?:number):Promise&lt;voi
copyFile(src: string | number, dest: string | number, mode: number, callback: AsyncCallback&lt;void&gt;): void
以异步方法复制文件,使用callback形式返回结果
复制文件,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -468,7 +466,7 @@ copyFileSync(src: string | number, dest: string | number, mode?: number): void
mkdir(path:string, mode?: number): Promise&lt;void&gt;
以异步方法创建目录,使用promise形式返回结果
创建目录,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -481,12 +479,12 @@ mkdir(path:string, mode?: number): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.mkdir(path).then(function() {
console.info("mkdir successfully");
console.info("mkdir succeed");
}).catch(function (error){
console.info("mkdir failed with error:"+ error);
});
......@@ -497,7 +495,7 @@ mkdir(path:string, mode?: number): Promise&lt;void&gt;
mkdir(path: string, mode: number, callback: AsyncCallback&lt;void&gt;): void
以异步方法创建目录,使用callback形式返回结果
创建目录,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -511,7 +509,7 @@ mkdir(path: string, mode: number, callback: AsyncCallback&lt;void&gt;): void
**示例:**
```js
fileio.mkdir(path, function(err) {
console.info("mkdir successfully");
console.info("mkdir succeed");
});
```
......@@ -540,7 +538,7 @@ mkdirSync(path: string, mode?: number): void
open(path: string, flags?: number, mode?: number): Promise&lt;number&gt;
以异步的方法打开文件,使用promise形式返回结果
打开文件,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -554,12 +552,12 @@ open(path: string, flags?: number, mode?: number): Promise&lt;number&gt;
**返回值:**
| 类型 | 说明 |
| --------------------- | ----------- |
| Promise&lt;number&gt; | 打开文件的文件描述符。 |
| Promise&lt;number&gt; | Promise对象。返回打开文件的文件描述符。 |
**示例:**
```js
fileio.open(path, 0o1, 0o0200).then(function(number){
console.info("open file successfully");
console.info("open file succeed");
}).catch(function(error){
console.info("open file failed with error:"+ err);
});
......@@ -570,7 +568,7 @@ open(path: string, flags?: number, mode?: number): Promise&lt;number&gt;
open(path: string, flags: number, mode: number, callback: AsyncCallback&lt;number&gt;): void
以异步的方法打开文件,使用callback形式返回结果
打开文件,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -624,7 +622,7 @@ read(fd: number, buffer: ArrayBuffer, options?: {
position?: number;
}): Promise&lt;ReadOut&gt;
以异步方法从文件读取数据,使用promise形式返回结果
从文件读取数据,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -639,14 +637,14 @@ read(fd: number, buffer: ArrayBuffer, options?: {
| 类型 | 说明 |
| ---------------------------------- | ------ |
| Promise&lt;[ReadOut](#readout)&gt; | 读取的结果。 |
| Promise&lt;[ReadOut](#readout)&gt; | Promise对象。返回读取的结果。 |
**示例:**
```js
let fd = fileio.openSync(path, 0o2);
let buf = new ArrayBuffer(4096);
fileio.read(fd, buf).then(function(readout){
console.info("read file data successfully");
console.info("read file data succeed");
console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
}).catch(function(error){
console.info("read file data failed with error:"+ error);
......@@ -662,7 +660,7 @@ read(fd: number, buffer: ArrayBuffer, options: {
position?: number;
}, callback: AsyncCallback&lt;ReadOut&gt;): void
以异步方法从文件读取数据,使用callback形式返回结果
从文件读取数据,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -680,7 +678,7 @@ read(fd: number, buffer: ArrayBuffer, options: {
let buf = new ArrayBuffer(4096);
fileio.read(fd, buf, function (err, readOut) {
if (readOut) {
console.info("read file data successfully");
console.info("read file data succeed");
console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
}
});
......@@ -723,7 +721,7 @@ readSync(fd: number, buffer: ArrayBuffer, options?: {
rmdir(path: string): Promise&lt;void&gt;
以异步方法删除目录,使用promise形式返回结果
删除目录,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -735,12 +733,12 @@ rmdir(path: string): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.rmdir(path).then(function() {
console.info("rmdir successfully");
console.info("rmdir succeed");
}).catch(function(err){
console.info("rmdir failed with error:"+ err);
});
......@@ -751,7 +749,7 @@ rmdir(path: string): Promise&lt;void&gt;
rmdir(path: string, callback:AsyncCallback&lt;void&gt;): void
以异步方法删除目录,使用callback形式返回结果
删除目录,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -765,7 +763,7 @@ rmdir(path: string, callback:AsyncCallback&lt;void&gt;): void
```js
fileio.rmdir(path, function(err){
// do something
console.info("rmdir successfully");
console.info("rmdir succeed");
});
```
......@@ -793,7 +791,7 @@ rmdirSync(path: string): void
unlink(path:string): Promise&lt;void&gt;
以异步方法删除文件,使用promise形式返回结果
删除文件,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -805,12 +803,12 @@ unlink(path:string): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.unlink(path).then(function(){
console.info("remove file successfully");
console.info("remove file succeed");
}).catch(function(error){
console.info("remove file failed with error:"+ error);
});
......@@ -821,7 +819,7 @@ unlink(path:string): Promise&lt;void&gt;
unlink(path:string, callback:AsyncCallback&lt;void&gt;): void
以异步方法删除文件,使用callback形式返回结果
删除文件,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -834,7 +832,7 @@ unlink(path:string, callback:AsyncCallback&lt;void&gt;): void
**示例:**
```js
fileio.unlink(path, function(err) {
console.info("remove file successfully");
console.info("remove file succeed");
});
```
......@@ -867,7 +865,7 @@ write(fd: number, buffer: ArrayBuffer | string, options?: {
encoding?: string;
}): Promise&lt;number&gt;
以异步方法将数据写入文件,使用promise形式返回结果
将数据写入文件,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -881,13 +879,13 @@ write(fd: number, buffer: ArrayBuffer | string, options?: {
**返回值:**
| 类型 | 说明 |
| --------------------- | -------- |
| Promise&lt;number&gt; | 实际写入的长度。 |
| Promise&lt;number&gt; | Promise对象。返回实际写入的长度。 |
**示例:**
```js
let fd = fileio.openSync(fpath, 0o100 | 0o2, 0o666);
fileio.write(fd, "hello, world").then(function(number){
console.info("write data to file successfully and size is:"+ number);
console.info("write data to file succeed and size is:"+ number);
}).catch(function(err){
console.info("write data to file failed with error:"+ err);
});
......@@ -903,7 +901,7 @@ write(fd: number, buffer: ArrayBuffer | string, options: {
encoding?: string;
}, callback: AsyncCallback&lt;number&gt;): void
以异步方法将数据写入文件,使用callback形式返回结果
将数据写入文件,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -920,7 +918,7 @@ write(fd: number, buffer: ArrayBuffer | string, options: {
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, "hello, world", function (err, bytesWritten) {
if (bytesWritten) {
console.info("write data to file successfully and size is:"+ bytesWritten);
console.info("write data to file succeed and size is:"+ bytesWritten);
}
});
```
......@@ -962,7 +960,7 @@ writeSync(fd: number, buffer: ArrayBuffer | string, options?: {
hash(path: string, algorithm: string): Promise&lt;string&gt;
以异步方法计算文件的哈希值,使用promise形式返回结果
计算文件的哈希值,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -975,12 +973,12 @@ hash(path: string, algorithm: string): Promise&lt;string&gt;
**返回值:**
| 类型 | 说明 |
| --------------------- | -------------------------- |
| Promise&lt;string&gt; | 文件的哈希值。表示为十六进制数字串,所有字母均大写。 |
| Promise&lt;string&gt; | Promise对象。返回文件的哈希值。表示为十六进制数字串,所有字母均大写。 |
**示例:**
```js
fileio.hash(path, "sha256").then(function(str){
console.info("calculate file hash successfully:"+ str);
console.info("calculate file hash succeed:"+ str);
}).catch(function(error){
console.info("calculate file hash failed with error:"+ err);
});
......@@ -991,7 +989,7 @@ hash(path: string, algorithm: string): Promise&lt;string&gt;
hash(path: string, algorithm: string, callback: AsyncCallback&lt;string&gt;): void
以异步方法计算文件的哈希值,使用callback形式返回结果
计算文件的哈希值,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1000,13 +998,13 @@ hash(path: string, algorithm: string, callback: AsyncCallback&lt;string&gt;): vo
| --------- | --------------------------- | ---- | ------------------------------------------------------------ |
| path | string | 是 | 待计算哈希值文件的应用沙箱路径。 |
| algorithm | string | 是 | 哈希计算采用的算法。可选&nbsp;"md5"、"sha1"&nbsp;&nbsp;"sha256"。建议采用安全强度更高的&nbsp;"sha256"。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步计算文件哈希操之后的回调函数(其中给定文件哈希值表示为十六进制数字串,所有字母均大写)。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步计算文件哈希操之后的回调函数(其中给定文件哈希值表示为十六进制数字串,所有字母均大写)。 |
**示例:**
```js
fileio.hash(fpath, "sha256", function(err, hashStr) {
if (hashStr) {
console.info("calculate file hash successfully:"+ hashStr);
console.info("calculate file hash succeed:"+ hashStr);
}
});
```
......@@ -1016,25 +1014,25 @@ hash(path: string, algorithm: string, callback: AsyncCallback&lt;string&gt;): vo
chmod(path: string, mode: number):Promise&lt;void&gt;
以异步方法基于文件路径改变文件权限,使用promise形式返回结果
改变文件权限,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| path | string | 是 | 待改变文件权限的应用沙箱路径。 |
| path | string | 是 | 所需变更权限的文件的应用沙箱路径。 |
| mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.chmod(path, mode).then(function() {
console.info("chmod successfully");
console.info("chmod succeed");
}).catch(function(err){
console.info("chmod failed with error:"+ err);
});
......@@ -1045,14 +1043,14 @@ chmod(path: string, mode: number):Promise&lt;void&gt;
chmod(path: string, mode: number, callback: AsyncCallback&lt;void&gt;): void
以异步方法基于文件路径改变文件权限,使用callback形式返回结果
改变文件权限,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| path | string | 是 | 待改变文件权限的应用沙箱路径。 |
| path | string | 是 | 所需变更权限的文件的应用沙箱路径。 |
| mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步改变文件权限之后的回调。 |
......@@ -1068,14 +1066,14 @@ chmod(path: string, mode: number, callback: AsyncCallback&lt;void&gt;): void
chmodSync(path: string, mode: number): void
以同步方法基于文件路径改变文件权限。
以同步方法改变文件权限。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| path | string | 是 | 待改变文件权限的应用沙箱路径。 |
| path | string | 是 | 所需变更权限的文件的应用沙箱路径。 |
| mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。 |
**示例:**
......@@ -1088,24 +1086,24 @@ chmodSync(path: string, mode: number): void
fstat(fd: number): Promise&lt;Stat&gt;
以异步方法基于文件描述符获取文件信息,使用promise形式返回结果
基于文件描述符获取文件状态信息,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待获取文件的文件描述符。 |
| fd | number | 是 | 待获取文件状态的文件描述符。 |
**返回值:**
| 类型 | 说明 |
| ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | 表示文件的具体信息。 |
| Promise&lt;[Stat](#stat)&gt; | Promise对象。返回表示文件状态的具体信息。 |
**示例:**
```js
fileio.fstat(fd).then(function(stat){
console.info("fstat successfully:"+ JSON.stringify(stat));
console.info("fstat succeed:"+ JSON.stringify(stat));
}).catch(function(err){
console.info("fstat failed with error:"+ err);
});
......@@ -1116,15 +1114,15 @@ fstat(fd: number): Promise&lt;Stat&gt;
fstat(fd: number, callback: AsyncCallback&lt;Stat&gt;): void
以异步方法基于文件描述符获取文件信息,使用callback形式返回结果
基于文件描述符获取文件状态信息,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------- | ---- | ---------------- |
| fd | number | 是 | 待获取文件的文件描述符。 |
| callback | AsyncCallback&lt;[Stat](#stat)&gt; | 是 | 异步获取文件信息之后的回调。 |
| fd | number | 是 | 待获取文件状态的文件描述符。 |
| callback | AsyncCallback&lt;[Stat](#stat)&gt; | 是 | 异步获取文件状态信息之后的回调。 |
**示例:**
```js
......@@ -1139,19 +1137,19 @@ fstat(fd: number, callback: AsyncCallback&lt;Stat&gt;): void
fstatSync(fd: number): Stat
以同步方法基于文件描述符获取文件信息。
以同步方法基于文件描述符获取文件状态信息。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待获取文件的文件描述符。 |
| fd | number | 是 | 待获取文件状态的文件描述符。 |
**返回值:**
| 类型 | 说明 |
| ------------- | ---------- |
| [Stat](#stat) | 表示文件的具体信息。 |
| [Stat](#stat) | 表示文件状态的具体信息。 |
**示例:**
```js
......@@ -1164,7 +1162,7 @@ fstatSync(fd: number): Stat
ftruncate(fd: number, len?: number): Promise&lt;void&gt;
以异步方法基于文件描述符截断文件,使用promise形式返回结果
基于文件描述符截断文件,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1172,18 +1170,18 @@ ftruncate(fd: number, len?: number): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------- |
| fd | number | 是 | 待截断文件的文件描述符。 |
| len | number | | 文件截断后的长度,以字节为单位。 |
| len | number | | 文件截断后的长度,以字节为单位。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。|
**示例:**
```js
let fd = fileio.openSync(path);
fileio.ftruncate(fd, 5).then(function(err) {
console.info("truncate file successfully");
console.info("truncate file succeed");
}).catch(function(err){
console.info("truncate file failed with error:"+ err);
});
......@@ -1194,7 +1192,7 @@ ftruncate(fd: number, len?: number): Promise&lt;void&gt;
ftruncate(fd: number, len: number, callback:AsyncCallback&lt;void&gt;): void
以异步方法基于文件描述符截断文件,使用callback形式返回结果
基于文件描述符截断文件,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1237,7 +1235,7 @@ ftruncateSync(fd: number, len?: number): void
truncate(path: string, len?: number): Promise&lt;void&gt;
以异步方法基于文件路径截断文件,使用promise形式返回结果
基于文件路径截断文件,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1245,17 +1243,17 @@ truncate(path: string, len?: number): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------------------------- |
| path | string | 是 | 待截断文件的应用沙箱路径。 |
| len | number | | 文件截断后的长度,以字节为单位。 |
| len | number | | 文件截断后的长度,以字节为单位。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.truncate(path, len).then(function(){
console.info("truncate file successfully");
console.info("truncate file succeed");
}).catch(function(err){
console.info("truncate file failed with error:"+ err);
});
......@@ -1266,7 +1264,7 @@ truncate(path: string, len?: number): Promise&lt;void&gt;
truncate(path: string, len: number, callback:AsyncCallback&lt;void&gt;): void
以异步方法基于文件路径截断文件,使用callback形式返回结果
基于文件路径截断文件,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1313,7 +1311,7 @@ readText(filePath: string, options?: {
encoding?: string;
}): Promise&lt;string&gt;
以异步方法基于文本方式读取文件(即直接读取文件的文本内容),使用promise形式返回结果
基于文本方式读取文件(即直接读取文件的文本内容),使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1326,12 +1324,12 @@ readText(filePath: string, options?: {
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------- |
| Promise&lt;string&gt; | 返回读取文件的内容。 |
| Promise&lt;string&gt; | Promise对象。返回读取文件的内容。 |
**示例:**
```js
fileio.readText(path).then(function(str) {
console.info("readText successfully:"+ str);
console.info("readText succeed:"+ str);
}).catch(function(err){
console.info("readText failed with error:"+ err);
});
......@@ -1346,7 +1344,7 @@ readText(filePath: string, options: {
encoding?: string;
}, callback: AsyncCallback&lt;string&gt;): void
以异步方法基于文本方式读取文件(即直接读取文件的文本内容),使用callback形式返回结果
基于文本方式读取文件(即直接读取文件的文本内容),使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1398,7 +1396,7 @@ readTextSync(filePath: string, options?: {
lstat(path: string): Promise&lt;Stat&gt;
以异步方法获取链接信息,使用promise形式返回结果
获取链接信息,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1410,12 +1408,12 @@ lstat(path: string): Promise&lt;Stat&gt;
**返回值:**
| 类型 | 说明 |
| ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | 表示文件的具体信息。 |
| Promise&lt;[Stat](#stat)&gt; | Promise对象。返回表示文件状态的具体信息。 |
**示例:**
```js
fileio.lstat(path).then(function(stat){
console.info("get link status successfully:"+ number);
console.info("get link status succeed:"+ number);
}).catch(function(err){
console.info("get link status failed with error:"+ err);
});
......@@ -1426,7 +1424,7 @@ lstat(path: string): Promise&lt;Stat&gt;
lstat(path:string, callback:AsyncCallback&lt;Stat&gt;): void
以异步方法获取链接信息,使用callback形式返回结果
获取链接信息,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1476,7 +1474,7 @@ read(buffer: ArrayBuffer, options?: {
length?: number;
}): Promise&lt;ReadOut&gt;
以异步方法从文件读取数据,使用promise形式返回结果
从文件读取数据,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1489,12 +1487,12 @@ read(buffer: ArrayBuffer, options?: {
**返回值:**
| 类型 | 说明 |
| ---------------------------------- | ------ |
| Promise&lt;[ReadOut](#readout)&gt; | 读取的结果。 |
| Promise&lt;[ReadOut](#readout)&gt; | Promise对象。返回读取的结果。 |
**示例:**
```js
fileio.read(new ArrayBuffer(4096)).then(function(readout){
console.info("read file data successfully");
console.info("read file data succeed");
console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
}).catch(function(err){
console.info("read file data failed with error:"+ err);
......@@ -1510,7 +1508,7 @@ read(buffer: ArrayBuffer, options: {
length?: number;
}, callback: AsyncCallback&lt;ReadOut&gt;): void
异步方法从文件读取数据,使用callback形式返回结果
从文件读取数据,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1526,7 +1524,7 @@ read(buffer: ArrayBuffer, options: {
let buf = new ArrayBuffer(4096);
fileio.read(buf, function (err, readOut) {
if (readOut) {
console.info("read file data successfully");
console.info("read file data succeed");
console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
}
});
......@@ -1537,7 +1535,7 @@ read(buffer: ArrayBuffer, options: {
rename(oldPath: string, newPath: string): Promise&lt;void&gt;
以异步方法重命名文件,使用promise形式返回结果
重命名文件,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1550,12 +1548,12 @@ rename(oldPath: string, newPath: string): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.rename(oldPath, newPath).then(function() {
console.info("rename successfully");
console.info("rename succeed");
}).catch(function(err){
console.info("rename failed with error:"+ err);
});
......@@ -1566,7 +1564,7 @@ rename(oldPath: string, newPath: string): Promise&lt;void&gt;
rename(oldPath: string, newPath: string, callback: AsyncCallback&lt;void&gt;): void
以异步方法重命名文件,使用callback形式返回结果
重命名文件,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1608,7 +1606,7 @@ renameSync(oldPath: string, newPath: string): void
fsync(fd: number): Promise&lt;void&gt;
以异步方法同步文件数据,使用promise形式返回结果
同步文件数据,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1620,12 +1618,12 @@ fsync(fd: number): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.fsync(fd).then(function(){
console.info("sync data successfully");
console.info("sync data succeed");
}).catch(function(err){
console.info("sync data failed with error:"+ err);
});
......@@ -1636,7 +1634,7 @@ fsync(fd: number): Promise&lt;void&gt;
fsync(fd: number, callback: AsyncCallback&lt;void&gt;): void
以异步方法同步文件数据,使用callback形式返回结果
同步文件数据,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1677,7 +1675,7 @@ fsyncSync(fd: number): void
fdatasync(fd: number): Promise&lt;void&gt;
以异步方法实现文件内容数据同步,使用promise形式返回结果
实现文件内容数据同步,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1689,12 +1687,12 @@ fdatasync(fd: number): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果,本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.fdatasync(fd).then(function(err) {
console.info("sync data successfully");
console.info("sync data succeed");
}).catch(function(err){
console.info("sync data failed with error:"+ err);
});
......@@ -1705,7 +1703,7 @@ fdatasync(fd: number): Promise&lt;void&gt;
fdatasync(fd: number, callback:AsyncCallback&lt;void&gt;): void
以异步方法实现文件内容数据同步,使用callback形式返回结果
实现文件内容数据同步,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1746,7 +1744,7 @@ fdatasyncSync(fd: number): void
symlink(target: string, srcPath: string): Promise&lt;void&gt;
以异步方法基于文件路径创建符号链接,使用promise形式返回结果
基于文件路径创建符号链接,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1759,12 +1757,12 @@ symlink(target: string, srcPath: string): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果,本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.symlink(target, srcPath).then(function() {
console.info("symlink successfully");
console.info("symlink succeed");
}).catch(function(err){
console.info("symlink failed with error:"+ err);
});
......@@ -1775,7 +1773,7 @@ symlink(target: string, srcPath: string): Promise&lt;void&gt;
symlink(target: string, srcPath: string, callback: AsyncCallback&lt;void&gt;): void
以异步方法基于文件路径创建符号链接,使用callback形式返回结果
基于文件路径创建符号链接,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1818,7 +1816,7 @@ symlinkSync(target: string, srcPath: string): void
chown(path: string, uid: number, gid: number): Promise&lt;void&gt;
以异步的方法基于文件路径改变文件所有者,使用promise形式返回结果
基于文件路径改变文件所有者,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1832,13 +1830,13 @@ chown(path: string, uid: number, gid: number): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果,本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
let stat = fileio.statSync(path);
fileio.chown(path, stat.uid, stat.gid).then(function(){
console.info("chown successfully");
console.info("chown succeed");
}).catch(function(err){
console.info("chown failed with error:"+ err);
});
......@@ -1849,7 +1847,7 @@ chown(path: string, uid: number, gid: number): Promise&lt;void&gt;
chown(path: string, uid: number, gid: number, callback: AsyncCallback&lt;void&gt;): void
以异步的方法基于文件路径改变文件所有者,使用callback形式返回结果
基于文件路径改变文件所有者,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1896,7 +1894,7 @@ chownSync(path: string, uid: number, gid: number): void
mkdtemp(prefix: string): Promise&lt;string&gt;
以异步的方法创建临时目录,使用promise形式返回结果
创建临时目录,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1908,12 +1906,12 @@ mkdtemp(prefix: string): Promise&lt;string&gt;
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------- |
| Promise&lt;string&gt; | 生成的唯一目录路径。 |
| Promise&lt;string&gt; | Promise对象。返回生成的唯一目录路径。 |
**示例:**
```js
fileio.mkdtemp(path + "XXXX").then(function(path){
console.info("mkdtemp successfully:"+ path);
console.info("mkdtemp succeed:"+ path);
}).catch(function(err){
console.info("mkdtemp failed with error:"+ err);
});
......@@ -1924,7 +1922,7 @@ mkdtemp(prefix: string): Promise&lt;string&gt;
mkdtemp(prefix: string, callback: AsyncCallback&lt;string&gt;): void
以异步的方法创建临时目录,使用callback形式返回结果
创建临时目录,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1970,7 +1968,7 @@ mkdtempSync(prefix: string): string
fchmod(fd: number, mode: number): Promise&lt;void&gt;
以异步方法基于文件描述符改变文件权限,使用promise形式返回结果
基于文件描述符改变文件权限,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -1983,12 +1981,12 @@ fchmod(fd: number, mode: number): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果,本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
fileio.fchmod(fd, mode).then(function() {
console.info("chmod successfully");
console.info("chmod succeed");
}).catch(function(err){
console.info("chmod failed with error:"+ err);
});
......@@ -1999,7 +1997,7 @@ fchmod(fd: number, mode: number): Promise&lt;void&gt;
fchmod(fd: number, mode: number, callback: AsyncCallback&lt;void&gt;): void
以异步方法基于文件描述符改变文件权限,使用callback形式返回结果
基于文件描述符改变文件权限,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2042,7 +2040,7 @@ fchmodSync(fd: number, mode: number): void
createStream(path: string, mode: string): Promise&lt;Stream&gt;
以异步方法基于文件路径打开文件流,使用promise形式返回结果
基于文件路径打开文件流,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2055,12 +2053,12 @@ createStream(path: string, mode: string): Promise&lt;Stream&gt;
**返回值:**
| 类型 | 说明 |
| --------------------------------- | --------- |
| Promise&lt;[Stream](#stream7)&gt; | 返回文件流的结果。 |
| Promise&lt;[Stream](#stream7)&gt; | Promise对象。返回文件流的结果。 |
**示例:**
```js
fileio.createStream(path, "r+").then(function(stream){
console.info("createStream successfully");
console.info("createStream succeed");
}).catch(function(err){
console.info("createStream failed with error:"+ err);
});
......@@ -2071,7 +2069,7 @@ createStream(path: string, mode: string): Promise&lt;Stream&gt;
createStream(path: string, mode: string, callback: AsyncCallback&lt;Stream&gt;): void
以异步方法基于文件路径打开文件流,使用callback形式返回结果
基于文件路径打开文件流,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2119,7 +2117,7 @@ createStreamSync(path: string, mode: string): Stream
fdopenStream(fd: number, mode: string): Promise&lt;Stream&gt;
以异步方法基于文件描述符打开文件流,使用promise形式返回结果
基于文件描述符打开文件流,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2132,12 +2130,12 @@ fdopenStream(fd: number, mode: string): Promise&lt;Stream&gt;
**返回值:**
| 类型 | 说明 |
| --------------------------------- | --------- |
| Promise&lt;[Stream](#stream7)&gt; | 返回文件流的结果。 |
| Promise&lt;[Stream](#stream7)&gt; | Promise对象。返回文件流的结果。 |
**示例:**
```js
fileio.fdopenStream(fd, mode).then(function(stream){
console.info("openStream successfully");
console.info("openStream succeed");
}).catch(function(err){
console.info("openStream failed with error:"+ err);
});
......@@ -2148,7 +2146,7 @@ fdopenStream(fd: number, mode: string): Promise&lt;Stream&gt;
fdopenStream(fd: number, mode: string, callback: AsyncCallback&lt;Stream&gt;): void
以异步方法基于文件描述符打开文件流,使用callback形式返回结果
基于文件描述符打开文件流,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2196,7 +2194,7 @@ fdopenStreamSync(fd: number, mode: string): Stream
fchown(fd: number, uid: number, gid: number): Promise&lt;void&gt;
以异步方法基于文件描述符改变文件所有者,使用promise形式返回结果
基于文件描述符改变文件所有者,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2210,13 +2208,13 @@ fchown(fd: number, uid: number, gid: number): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
let stat = fileio.statSync(path);
fileio.fchown(fd, stat.uid, stat.gid).then(function() {
console.info("chown successfully");
console.info("chown succeed");
}).catch(function(err){
console.info("chown failed with error:"+ err);
});
......@@ -2227,7 +2225,7 @@ fchown(fd: number, uid: number, gid: number): Promise&lt;void&gt;
fchown(fd: number, uid: number, gid: number, callback: AsyncCallback&lt;void&gt;): void
以异步方法基于文件描述符改变文件所有者,使用callback形式返回结果
基于文件描述符改变文件所有者,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2274,7 +2272,7 @@ fchownSync(fd: number, uid: number, gid: number): void
lchown(path: string, uid: number, gid: number): Promise&lt;void&gt;
以异步方法基于文件路径改变文件所有者,更改符号链接本身的所有者,而不是符号链接所指向的实际文件,使用promise形式返回结果
基于文件路径改变文件所有者,更改符号链接本身的所有者,而不是符号链接所指向的实际文件,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2288,13 +2286,13 @@ lchown(path: string, uid: number, gid: number): Promise&lt;void&gt;
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。本调用将返回空值。 |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
let stat = fileio.statSync(path);
fileio.lchown(path, stat.uid, stat.gid).then(function() {
console.info("chown successfully");
console.info("chown succeed");
}).catch(function(err){
console.info("chown failed with error:"+ err);
});
......@@ -2305,7 +2303,7 @@ lchown(path: string, uid: number, gid: number): Promise&lt;void&gt;
lchown(path: string, uid: number, gid: number, callback: AsyncCallback&lt;void&gt;): void
以异步方法基于文件路径改变文件所有者,更改符号链接本身的所有者,而不是更改符号链接所指向的实际文件,使用callback形式返回结果
基于文件路径改变文件所有者,更改符号链接本身的所有者,而不是更改符号链接所指向的实际文件,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2352,7 +2350,7 @@ lchownSync(path: string, uid: number, gid: number): void
createWatcher(filename: string, events: number, callback: AsyncCallback&lt;number&gt;): Watcher
以异步方法监听文件或者目录的变化,使用callback形式返回结果
监听文件或者目录的变化,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2366,7 +2364,7 @@ createWatcher(filename: string, events: number, callback: AsyncCallback&lt;numbe
**返回值:**
| 类型 | 说明 |
| -------------------- | ---------- |
| [Watcher](#watcher7) | 文件变化监听的实例。 |
| [Watcher](#watcher7) | Promise对象。返回文件变化监听的实例。 |
**示例:**
```js
......@@ -2555,7 +2553,7 @@ Watcher是文件变化监听的实例,调用Watcher.stop()方法(同步或
stop(): Promise&lt;void&gt;
以异步方法关闭watcher监听,使用promise形式返回结果
关闭watcher监听,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2569,7 +2567,7 @@ stop(): Promise&lt;void&gt;
stop(callback: AsyncCallback&lt;void&gt;): void
以异步方法关闭watcher监听,使用callback形式返回结果
关闭watcher监听,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2595,20 +2593,20 @@ stop(callback: AsyncCallback&lt;void&gt;): void
close(): Promise&lt;void&gt;
异步关闭文件流,使用promise形式返回结果
关闭文件流,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------- |
| Promise&lt;void&gt; | 表示异步关闭文件流的结果。 |
| Promise&lt;void&gt; | Promise对象。返回表示异步关闭文件流的结果。 |
**示例:**
```js
let ss= fileio.createStreamSync(path);
ss.close().then(function(){
console.info("close fileStream successfully");
console.info("close fileStream succeed");
}).catch(function(err){
console.info("close fileStream failed with error:"+ err);
});
......@@ -2619,7 +2617,7 @@ close(): Promise&lt;void&gt;
close(callback: AsyncCallback&lt;void&gt;): void
异步关闭文件流,使用callback形式返回结果
异步关闭文件流,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2656,20 +2654,20 @@ closeSync(): void
flush(): Promise&lt;void&gt;
异步刷新文件流,使用promise形式返回结果
刷新文件流,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------- |
| Promise&lt;void&gt; | 表示异步刷新文件流的结果。 |
| Promise&lt;void&gt; | Promise对象。返回表示异步刷新文件流的结果。 |
**示例:**
```js
let ss= fileio.createStreamSync(path);
ss.flush().then(function (){
console.info("flush successfully");
console.info("flush succeed");
}).catch(function(err){
console.info("flush failed with error:"+ err);
});
......@@ -2680,7 +2678,7 @@ flush(): Promise&lt;void&gt;
flush(callback: AsyncCallback&lt;void&gt;): void
异步刷新文件流,使用callback形式返回结果
异步刷新文件流,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2722,7 +2720,7 @@ write(buffer: ArrayBuffer | string, options?: {
encoding?: string;
}): Promise&lt;number&gt;
以异步方法将数据写入流文件,使用promise形式返回结果
将数据写入流文件,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2735,13 +2733,13 @@ write(buffer: ArrayBuffer | string, options?: {
**返回值:**
| 类型 | 说明 |
| --------------------- | -------- |
| Promise&lt;number&gt; | 实际写入的长度。 |
| Promise&lt;number&gt; | Promise对象。返回实际写入的长度。 |
**示例:**
```js
let ss= fileio.createStreamSync(fpath, "r+");
ss.write("hello, world",{offset: 1,length: 5,position: 5,encoding :'utf-8'}).then(function (number){
console.info("write successfully and size is:"+ number);
console.info("write succeed and size is:"+ number);
}).catch(function(err){
console.info("write failed with error:"+ err);
});
......@@ -2757,7 +2755,7 @@ write(buffer: ArrayBuffer | string, options: {
encoding?: string;
}, callback: AsyncCallback&lt;number&gt;): void
以异步方法将数据写入流文件,使用callback形式返回结果
将数据写入流文件,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2774,7 +2772,7 @@ write(buffer: ArrayBuffer | string, options: {
ss.write("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}, function (err, bytesWritten) {
if (bytesWritten) {
// do something
console.info("write successfully and size is:"+ bytesWritten);
console.info("write succeed and size is:"+ bytesWritten);
}
});
```
......@@ -2819,7 +2817,7 @@ read(buffer: ArrayBuffer, options?: {
length?: number;
}): Promise&lt;ReadOut&gt;
以异步方法从流文件读取数据,使用promise形式返回结果
从流文件读取数据,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2832,13 +2830,13 @@ read(buffer: ArrayBuffer, options?: {
**返回值:**
| 类型 | 说明 |
| ---------------------------------- | ------ |
| Promise&lt;[ReadOut](#readout)&gt; | 读取的结果。 |
| Promise&lt;[ReadOut](#readout)&gt; | Promise对象。返回读取的结果。 |
**示例:**
```js
let ss = fileio.createStreamSync(fpath, "r+");
ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readout){
console.info("read data successfully");
console.info("read data succeed");
console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
}).catch(function(err){
console.info("read data failed with error:"+ err);
......@@ -2854,7 +2852,7 @@ read(buffer: ArrayBuffer, options: {
length?: number;
}, callback: AsyncCallback&lt;ReadOut&gt;): void
以异步方法从流文件读取数据,使用callback形式返回结果
从流文件读取数据,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2870,7 +2868,7 @@ read(buffer: ArrayBuffer, options: {
let ss = fileio.createStreamSync(fpath, "r+");
ss.read(new ArrayBuffer(4096),{offset: 1, length: 5, position: 5},function (err, readOut) {
if (readOut) {
console.info("read data successfully");
console.info("read data succeed");
console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)));
}
});
......@@ -2918,20 +2916,20 @@ readSync(buffer: ArrayBuffer, options?: {
read(): Promise&lt;Dirent&gt;
异步读取下一个目录项,使用promise形式返回结果
读取下一个目录项,使用Promise异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| -------------------------------- | ------------- |
| Promise&lt;[Dirent](#dirent)&gt; | 表示异步读取目录项的结果。 |
| Promise&lt;[Dirent](#dirent)&gt; | Promise对象。返回表示异步读取目录项的结果。 |
**示例:**
```js
let dir = fileio.opendirSync(path);
dir.read().then(function (dirent){
console.log("read successfully:"+JSON.stringify(dirent));
console.log("read succeed:"+JSON.stringify(dirent));
}).catch(function(err){
console.info("read failed with error:"+ err);
});
......@@ -2942,7 +2940,7 @@ read(): Promise&lt;Dirent&gt;
read(callback: AsyncCallback&lt;Dirent&gt;): void
异步读取下一个目录项,使用callback形式返回结果
读取下一个目录项,使用callback异步回调
**系统能力**:SystemCapability.FileManagement.File.FileIO
......@@ -2957,7 +2955,7 @@ read(callback: AsyncCallback&lt;Dirent&gt;): void
dir.read(function (err, dirent) {
if (dirent) {
// do something
console.log("read successfully:"+JSON.stringify(dirent));
console.log("read succeed:"+JSON.stringify(dirent));
}
});
```
......
# 日志打印
hilog日志系统,使应用/服务可以按照指定级别、标识和格式字符串输出日志内容,帮助开发者了解应用/服务的运行状态,更好地调试程序。
以下文档仅对接口功能进行描述,具体的日志打印要求请参考[OpenHarmony日志打印规范](../../../contribute/OpenHarmony-Log-guide.md)
> **说明:**
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......
......@@ -26,7 +26,7 @@ on(type: “change”, listener: Callback&lt;DeviceListener&gt;): void
**参数**
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | -------------------- |
| -------- | ---------------------------------------- | ---- | ----------- |
| type | string | 是 | 输入设备的事件类型。 |
| listener | Callback&lt;[DeviceListener](#devicelistener<sup>9+</sup>)&gt; | 是 | 可上报的输入设备事件。 |
......@@ -61,7 +61,7 @@ off(type: “change”, listener?: Callback&lt;DeviceListener&gt;): void
**参数**
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | -------------------- |
| -------- | ---------------------------------------- | ---- | ----------- |
| type | string | 是 | 输入设备的事件类型。 |
| listener | Callback&lt;[DeviceListener](#devicelistener<sup>9+</sup>)&gt; | 否 | 可上报的输入设备事件。 |
......@@ -113,7 +113,7 @@ function getDeviceIds(): Promise&lt;&lt;Array&lt;number&gt;&gt;
**返回值**
| 参数 | 说明 |
| ------------------------- | ----------------------------- |
| ---------------------------------- | ------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise实例,用于异步获取结果。 |
**示例**
......@@ -159,13 +159,13 @@ function getDevice(deviceId: number): Promise&lt;InputDeviceData&gt;
**参数**
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------------- |
| -------- | ------ | ---- | ------------ |
| deviceId | number | 是 | 需要获取信息的设备id。 |
**返回值**
| 参数 | 说明 |
| -------------------------------------------------- | ----------------------------- |
| ---------------------------------------- | ------------------- |
| Promise&lt;[InputDeviceData](#inputdevicedata)&gt; | Promise实例,用于异步获取结果。 |
**示例**
......@@ -188,7 +188,7 @@ supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;, callback: Callback&lt;
**参数**
| 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
| -------- | ------------------------------------ | ---- | --------------------------------- |
| deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| keys | Array&lt;KeyCode&gt; | 是 | 需要查询的键码值,最多支持5个按键查询。 |
| callback | Callback&lt;Array&lt;boolean&gt;&gt; | 是 | 回调函数,异步返回查询结果。 |
......@@ -213,14 +213,14 @@ supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;): Promise&lt;Array&lt;b
**参数**
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------------------------------------ |
| -------- | -------------------- | ---- | --------------------------------- |
| deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| keys | Array&lt;KeyCode&gt; | 是 | 需要查询的键码值,最多支持5个按键查询。 |
**返回值**
| 参数 | 说明 |
| ----------------------------------- | ----------------------------- |
| ----------------------------------- | ------------------- |
| Promise&lt;Array&lt;boolean&gt;&gt; | Promise实例,用于异步获取结果。 |
**示例**
......@@ -243,7 +243,7 @@ getKeyboardType(deviceId: number, callback: AsyncCallback&lt;KeyboardType&gt;):
**参数**
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
| -------- | ---------------------------------------- | ---- | --------------------------------- |
| deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| callback | AsyncCallback&lt;[KeyboardType](#keyboardtype)&gt; | 是 | 回调函数,异步返回查询结果。 |
......@@ -267,14 +267,14 @@ getKeyboardType(deviceId: number,): Promise&lt;KeyboardType&gt;;
**返回值**
| 参数 | 说明 |
| -------------------------------------------- | ----------------------------- |
| ---------------------------------------- | ------------------- |
| Promise&lt;[KeyboardType](#keyboardtype)&gt; | Promise实例,用于异步获取结果。 |
**示例**
```js
// 示例查询设备id为1的设备键盘类型。
inputDevice.getKeyboardType().then((ret)=>{
inputDevice.getKeyboardType(1).then((ret)=>{
console.log("The keyboard type of the device is: " + ret);
})
```
......@@ -286,7 +286,7 @@ inputDevice.getKeyboardType().then((ret)=>{
**系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| -------- | --------------------------- | ------------------------------------------------------------ |
| -------- | ------------------------- | --------------------------------- |
| type | [ChangeType](#changetype) | 表示输入设备插入或者移除。 |
| deviceId | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
......@@ -297,7 +297,7 @@ inputDevice.getKeyboardType().then((ret)=>{
**系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| -------------------- | -------------------------------------- | ------------------------------------------------------------ |
| -------------------- | -------------------------------------- | ---------------------------------------- |
| id | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| name | string | 输入设备的名字。 |
| sources | Array&lt;[SourceType](#sourcetype)&gt; | 输入设备支持的源类型。比如有的键盘上附带触摸板,则此设备有keyboard和touchpad两种输入源。 |
......@@ -316,7 +316,7 @@ inputDevice.getKeyboardType().then((ret)=>{
**系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| ----------- | -------- | ------------------- |
| ----------- | ------ | --------------- |
| touchMajor | string | 表示touchMajor轴。 |
| touchMinor | string | 表示touchMinor轴。 |
| toolMinor | string | 表示toolMinor轴。 |
......@@ -334,7 +334,7 @@ inputDevice.getKeyboardType().then((ret)=>{
**系统能力**: 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| ----------------------- | ------------------------- | ---------------- |
| ----------------------- | ------------------------- | -------- |
| source | [SourceType](#sourcetype) | 轴的输入源类型。 |
| axis | [AxisType](axistype) | 轴的类型。 |
| max | number | 轴的最大值。 |
......@@ -365,7 +365,7 @@ inputDevice.getKeyboardType().then((ret)=>{
**系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 说明 |
| ------ | -------- | ------------------ |
| ------ | ------ | --------- |
| add | string | 表示输入设备插入。 |
| remove | string | 表示输入设备移除。 |
......@@ -376,7 +376,7 @@ inputDevice.getKeyboardType().then((ret)=>{
**系统能力**:以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称 | 参数类型 | 值 | 说明 |
| ------------------- | -------- | ---- | ------------------ |
| ------------------- | ------ | ---- | --------- |
| NONE | number | 0 | 表示无按键设备。 |
| UNKNOWN | number | 1 | 表示未知按键设备。 |
| ALPHABETIC_KEYBOARD | number | 2 | 表示全键盘设备。 |
......
# 注入按键
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> **说明:**
>
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> - 本模块接口均为系统接口,三方应用不支持调用。
> 本模块接口均为系统接口,三方应用不支持调用。
## 导入模块
```
```js
import inputEventClient from '@ohos.multimodalInput.inputEventClient';
```
......@@ -27,19 +27,19 @@ injectEvent({KeyEvent: KeyEvent}): void
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| -------- | --------------------- | ---- | --------- |
| KeyEvent | [KeyEvent](#keyevent) | 是 | 注入按键的描述信息 |
**示例:**
```
```js
let keyEvent = {
isPressed: true,
keyCode: 2,
keyDownDuration: 0,
isIntercepted: false
}
res = inputEventClient.injectEvent({KeyEvent: keyEvent});
let res = inputEventClient.injectEvent({KeyEvent: keyEvent});
```
......@@ -50,7 +50,7 @@ res = inputEventClient.injectEvent({KeyEvent: keyEvent});
**系统能力:** 以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputSimulator
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| --------------- | ------- | ---- | --------- |
| isPressed | boolean | 是 | 按键是否按下 |
| keyCode | Number | 是 | 按键键值 |
| keyDownDuration | boolean | 是 | 按键按下持续时间 |
......
......@@ -153,7 +153,7 @@ getIndexOfKey(key: number): number
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
let result = plainArray.getIndexOfKey("sdfs");
let result = plainArray.getIndexOfKey(2);
```
......
......@@ -408,7 +408,7 @@ isNrSupported\(slotId: number\): boolean
```js
let slotId = 0;
let result = radio.isNrSupported(slotId);
console.log(result);
console.log("Result: "+ result);
```
......
......@@ -20,12 +20,12 @@ isScreenLocked(callback: AsyncCallback&lt;boolean&gt;): void
**系统能力**: SystemCapability.MiscServices.ScreenLock
- 参数
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,返回true表示屏幕已锁屏,返回false表示屏幕未锁屏。 |
- 示例
**示例**
```js
screenlock.isScreenLocked((err, data)=>{
......@@ -46,12 +46,12 @@ isScreenLocked(): Promise&lt;boolean&gt;
**系统能力**: SystemCapability.MiscServices.ScreenLock
- 返回值
**返回值**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;boolean&gt; | 以Promise形式返回结果。 |
- 示例
**示例**
```js
screenlock.isScreenLocked().then((data) => {
......@@ -73,12 +73,12 @@ isSecureMode(callback: AsyncCallback&lt;boolean&gt;): void
**系统能力**: SystemCapability.MiscServices.ScreenLock
- 参数
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。返回true表示屏幕处于安全模式下,返回false表示屏幕当前不在安全模式下。 |
- 示例
**示例**
```js
screenlock.isSecureMode((err, data)=>{
......@@ -99,12 +99,12 @@ isSecureMode(): Promise&lt;boolean&gt;
**系统能力**: SystemCapability.MiscServices.ScreenLock
- 返回值
**返回值**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;boolean&gt; | 以Promise形式返回结果。 |
- 示例
**示例**
```js
screenlock.isSecureMode().then((data) => {
......@@ -126,15 +126,15 @@ unlockScreen(callback: AsyncCallback&lt;void&gt;): void
**系统能力**: SystemCapability.MiscServices.ScreenLock
- 参数
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,失败时返回错误信息。 |
- 示例
**示例**
```js
screenlock.unlockScreen((err)=>{
screenlock.unlockScreen((err) => {
if (err) {
console.error('unlockScreen callback error -> ${JSON.stringify(err)}');
return;
......@@ -152,12 +152,12 @@ unlockScreen(): Promise&lt;void&gt;
**系统能力**: SystemCapability.MiscServices.ScreenLock
- 返回值
**返回值**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;void&gt; | 以Promise形式返回结果。 |
- 示例
**示例**
```js
screenlock.unlockScreen().then(() => {
......@@ -166,3 +166,141 @@ unlockScreen(): Promise&lt;void&gt;
console.error('unlockScreen fail, promise: err->${JSON.stringify(err)}');
});
```
## screenlock.on<sup>9+</sup>
on(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginScreenOff' | 'endScreenOff' | 'unlockScreen' | 'beginExitAnimation', callback: Callback\<void\>): void
注册锁屏状态变化回调。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 设置事件类型。<br/>- type为"beginWakeUp",表示事件开始时开始唤醒。<br/>- type为"endWakeUp",表示事件结束时结束唤醒。<br/>- type为"beginScreenOn",表示事件开始时开始亮屏。<br/>- type为"endScreenOn",表示事件结束时结束亮屏。<br/>- type为"beginScreenOff",表示事件开始时开始灭屏。<br/>- type为"endScreenOff",表示事件结束时结束灭屏。<br/>- type为"unlockScreen",表示请求解锁。<br/>- type为"beginExitAnimation",表示动画开始退场。 |
| callback | Callback\<void\> | 是 | 事件回调方法。 |
**示例**
```js
screenlock.on('beginWakeUp', () => {
console.log('beginWakeUp triggered');
});
```
## screenlock.on<sup>9+</sup>
on(type: 'beginSleep' | 'endSleep' | 'changeUser', callback: Callback\<number\>): void
注册锁屏状态变化回调。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 设置事件类型。<br/>- type为"beginSleep",表示开始休眠。<br/>- type为"endSleep",表示结束休眠。<br/>- type为"changeUser",表示切换用户。 |
| callback | Callback\<number\> | 是 | 事件回调方法。<br/>返回事件相应的状态。 |
**示例**
```js
screenlock.on('beginSleep', (why) => {
console.log('beginSleep triggered:' + why);
});
```
## screenlock.on<sup>9+</sup>
on(type: 'screenlockEnabled', callback: Callback\<boolean\>): void
注册锁屏状态变化回调。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 设置事件类型。<br/>- type为"screenlockEnabled",表示锁屏是否启用。 |
| callback | Callback\<boolean\> | 是 | 注册成功的回调。<br/>回调结果用true/false表示。 |
**示例**
```js
screenlock.on('screenlockEnabled', (isEnabled) => {
console.log('screenlockEnabled triggered, result:' + isEnabled);
});
```
## screenlock.off<sup>9+</sup>
off(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginScreenOff' | 'endScreenOff'
| 'unlockScreen' | 'beginExitAnimation' | 'screenlockEnabled' | 'beginSleep' | 'endSleep' | 'changeUser', callback: Callback\<void\>): void
取消注册锁屏状态变化回调。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 设置事件类型。<br/>- type为"beginWakeUp",表示事件开始时开始唤醒。<br/>- type为"endWakeUp",表示事件结束时结束唤醒。<br/>- type为"beginScreenOn",表示事件开始时开始亮屏。<br/>- type为"endScreenOn",表示事件结束时结束亮屏。<br/>- type为"beginScreenOff",表示事件开始时开始灭屏。<br/>- type为"endScreenOff",表示事件结束时结束灭屏。<br/>- type为"unlockScreen",表示请求解锁。<br/>- type为"beginExitAnimation",表示动画开始退场。<br/>- type为"screenlockEnabled",表示锁屏是否启用。<br/>- type为"beginSleep",表示开始休眠。<br/>- type为"endSleep",表示结束休眠。<br/>- type为"changeUser",表示切换用户。 |
| callback | Callback\<void\> | 是 | 注册成功的回调。 |
**示例**
```js
screenlock.off('beginWakeUp', () => {
console.log("callback");
});
```
## screenlock.sendScreenLockEvent<sup>9+</sup>
sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback\<boolean\>): void
应用发送事件到锁屏服务,异步方法。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| event | String | 是 | 事件类型,支持如下取值:<br/>- "unlockScreenResult",表示解锁结果。<br/>- "screenDrawDone",表示屏幕绘制完成。 |
| parameter | number | 是 | 解锁状态。<br/>- parameter为0,表示解锁成功。<br/>- parameter为1,表示解锁失败。<br/>- parameter为2,表示解锁取消。 |
| callback | AsyncCallback\<boolean\> | 是 | 表示执行结果。 |
**示例**
```js
screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => {
console.log('sending result:' + result);
});
```
## screenlock.sendScreenLockEvent<sup>9+</sup>
sendScreenLockEvent(event: String, parameter: number): Promise<boolean>
应用发送事件到锁屏服务,异步方法。
**系统能力**: SystemCapability.MiscServices.ScreenLock
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| event | String | 是 | 事件类型,支持如下取值:<br/>- "unlockScreenResult",表示解锁结果。<br/>- "screenDrawDone",表示屏幕绘制完成。 |
| parameter | number | 是 | 解锁状态。<br/>- parameter为0,表示解锁成功。<br/>- parameter为1,表示解锁失败。<br/>- parameter为2,表示解锁取消。 |
**返回值**
| 类型 | 说明 |
| -------- | -------- |
| Promise\<boolean\> | 以Promise形式返回执行结果。 |
**示例**
```js
screenlock.sendScreenLockEvent('unlockScreenResult', 0).then((err, result) => {
console.log('sending result:' + result);
});
```
# 传感器
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
```js
import sensor from '@ohos.sensor';
```
......@@ -30,7 +30,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Acceler
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -59,7 +59,7 @@ on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;Line
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -88,7 +88,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -118,7 +118,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespons
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -147,7 +147,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -176,7 +176,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;G
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -206,7 +206,7 @@ on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;Sig
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){
console.info('Scalar data: ' + data.scalar);
},
......@@ -233,7 +233,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;Pe
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){
console.info('Scalar data: ' + data.scalar);
},
......@@ -260,7 +260,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){
console.info('Steps: ' + data.steps);
},
......@@ -285,7 +285,7 @@ on(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;Ambie
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){
console.info('Temperature: ' + data.temperature);
},
......@@ -310,7 +310,7 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magneti
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -337,7 +337,7 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callbac
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -367,7 +367,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){
console.info('Distance: ' + data.distance);
},
......@@ -392,7 +392,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRespo
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){
console.info('Humidity: ' + data.humidity);
},
......@@ -417,7 +417,7 @@ on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){
console.info('Atmospheric pressure: ' + data.pressure);
},
......@@ -442,7 +442,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;,
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){
console.info('Status: ' + data.status);
},
......@@ -467,7 +467,7 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){
console.info(' Illumination: ' + data.intensity);
},
......@@ -492,7 +492,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientatio
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){
console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
......@@ -521,7 +521,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateRe
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){
console.info("Heart rate: " + data.heartRate);
},
......@@ -545,7 +545,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;Rotatio
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -573,7 +573,7 @@ on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDet
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:**
```
```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){
console.info('Wear status: ' + data.value);
},
......@@ -599,7 +599,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Accele
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -626,7 +626,7 @@ once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;Li
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -681,7 +681,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespo
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -708,7 +708,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeR
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -735,7 +735,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&l
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -763,7 +763,7 @@ once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;Si
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) {
console.info('Scalar data: ' + data.scalar);
}
......@@ -788,7 +788,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;P
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) {
console.info('Scalar data: ' + data.scalar);
}
......@@ -813,7 +813,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerR
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) {
console.info('Steps: ' + data.steps);
}
......@@ -836,7 +836,7 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;A
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) {
console.info('Temperature: ' + data.temperature);
}
......@@ -859,7 +859,7 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magne
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -884,7 +884,7 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callb
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -912,7 +912,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityR
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
......@@ -939,7 +939,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRes
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) {
console.info('Humidity: ' + data.humidity);
}
......@@ -962,7 +962,7 @@ once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerR
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) {
console.info('Atmospheric pressure: ' + data.pressure);
}
......@@ -985,7 +985,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) {
console.info('Status: ' + data.status);
}
......@@ -1008,7 +1008,7 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightR
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) {
console.info(' Illumination: ' + data.intensity);
}
......@@ -1031,7 +1031,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientat
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
......@@ -1056,7 +1056,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;Rota
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -1084,7 +1084,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRate
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) {
console.info("Heart rate: " + data.heartRate);
}
......@@ -1107,7 +1107,7 @@ once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearD
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |
**示例:**
```
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) {
console.info("Wear status: "+ data.value);
}
......@@ -1133,7 +1133,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;Accele
**示例:**
```
```js
function callback(data) {
console.info('x-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -1161,7 +1161,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callb
**示例:**
```
```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -1190,7 +1190,7 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback&lt;LightR
**示例:**
```
```js
function callback(data) {
console.info(' Illumination: ' + data.intensity);
}
......@@ -1214,7 +1214,7 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt;
**示例:**
```
```js
function callback(data) {
console.info('Temperature: ' + data.temperature);
}
......@@ -1238,7 +1238,7 @@ off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerR
**示例:**
```
```js
function callback(data) {
console.info('Atmospheric pressure: ' + data.pressure);
}
......@@ -1262,7 +1262,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityRespo
**示例:**
```
```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -1290,7 +1290,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeR
**示例:**
```
```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -1318,7 +1318,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback&
**示例:**
```
```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -1344,7 +1344,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback&lt;HallResponse&gt
**示例:**
```
```js
function callback(data) {
console.info('Status: ' + data.status);
}
......@@ -1370,7 +1370,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback&lt;HeartRate
**示例:**
```
```js
function callback(data) {
console.info("Heart rate: " + data.heartRate);
}
......@@ -1396,7 +1396,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityRes
**示例:**
```
```js
function callback(data) {
console.info('Humidity: ' + data.humidity);
}
......@@ -1422,7 +1422,7 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt;
**示例:**
```
```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -1450,7 +1450,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback);
**示例:**
```
```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -1476,7 +1476,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback);
**示例:**
```
```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -1505,7 +1505,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callbac
**示例:**
```
```js
function callback(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
......@@ -1531,7 +1531,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerR
**返回值:** ;
```
```js
function callback(data) {
console.info('Steps: ' + data.steps);
}
......@@ -1557,7 +1557,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt;
**示例:**
```
```js
function callback(data) {
console.info('Scalar data: ' + data.scalar);
}
......@@ -1581,7 +1581,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityR
**示例:**
```
```js
function callback(data) {
console.info('Distance: ' + data.distance);
}
......@@ -1605,7 +1605,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;Rota
**示例:**
```
```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
......@@ -1632,7 +1632,7 @@ off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback&lt;S
**示例:**
```
```js
function callback(data) {
console.info('Scalar data: ' + data.scalar);
}
......@@ -1656,7 +1656,7 @@ off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearD
**示例:**
```
```js
function accCallback(data) {
console.info('Wear status: ' + data.value);
}
......@@ -1681,13 +1681,13 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co
**示例:**
```
sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}, function(err, data) {
```js
sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(err, data) {
if (err) {
console.error("Operation failed. Error code: " + err.code + ", message: " + err.message);
return;
}
console.info("Operation successed. Data obtained: " + data.x);
console.info("Operation successed. Data obtained: " + data);
for (var i=0; i < data.length; i++) {
console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
}
......@@ -1716,8 +1716,8 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co
**示例:**
```
const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3});
```js
const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3});
promise.then((data) => {
console.info("Operation successed.");
for (var i=0; i < data.length; i++) {
......@@ -1744,8 +1744,8 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callba
| callback | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 是 | 返回磁场信息。 |
**示例:**
```
sensor.getGeomagneticField([80, 0, 0], 1580486400000, function(err, data) {
```js
sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000, function(err, data) {
if (err) {
console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message);
return;
......@@ -1775,8 +1775,8 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promi
| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 返回磁场信息。 |
**返回值:**
```
const promise = sensor.getGeomagneticField([80, 0, 0], 1580486400000);
```js
const promise = sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000);
promise.then((data) => {
console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' +
data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
......@@ -1804,7 +1804,7 @@ getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallbac
**返回值:**
```
```js
sensor.getAltitude(0, 200, function(err, data) {
if (err) {
console.error(
......@@ -1838,7 +1838,7 @@ getAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt;
**返回值:**
```
```js
const promise = sensor.getAltitude(0, 200);
promise.then((data) => {
console.info(' sensor_getAltitude_Promise success', data);
......@@ -1865,10 +1865,10 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallbac
**返回值:**
```
```js
sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
......@@ -1898,7 +1898,7 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt;
**返回值:**
```
```js
const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => {
console.info(' getGeomagneticDip_promise successed', data);
......@@ -1925,10 +1925,10 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar
**返回值:**
```
```js
sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) {
if (err) {
console.error(LABEL + 'Failed to register data, error code is: ' + err.code + ', message: ' +
console.error('Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
......@@ -1963,10 +1963,10 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar
**返回值:**
```
```js
const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]);
promise.then((data) => {
console.info(LABEL + 'getAngleModifiy_promise success');
console.info('getAngleModifiy_promise success');
for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]);
}
......@@ -1993,10 +1993,10 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallbac
**返回值:**
```
```js
sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
......@@ -2030,10 +2030,10 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;n
**返回值:**
```
```js
const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => {
console.info(LABEL + 'createRotationMatrix_promise success');
console.info('createRotationMatrix_promise success');
for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]);
}
......@@ -2060,10 +2060,10 @@ createQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt
**返回值:**
```
```js
sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
......@@ -2097,12 +2097,12 @@ createQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;numbe
**返回值:**
```
```js
const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => {
console.info('createQuaternion_promise successed');
for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]);
console.info("data[" + i + "]: " + data[i]);
}
}).catch((err) => {
console.info('promise failed');
......@@ -2127,16 +2127,16 @@ getDirection(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Arr
**返回值:**
```
```js
sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
console.info(LABEL + "SensorJsAPI--->Successed to get getDirection interface get data: " + data.x);
console.info("SensorJsAPI--->Successed to get getDirection interface get data: " + data.x);
for (var i = 1; i < data.length; i++) {
console.info(TAG +"sensor_getDirection_callback" + data[i]);
console.info("sensor_getDirection_callback" + data[i]);
}
})
```
......@@ -2164,12 +2164,12 @@ getDirection(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt
**返回值:**
```
```js
const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => {
console.info(' sensor_getAltitude_Promise success', data.x);
console.info('sensor_getAltitude_Promise success', data.x);
for (var i = 1; i < data.length; i++) {
console.info(TAG +"sensor_getDirection_promise" + data[i]);
console.info("sensor_getDirection_promise" + data[i]);
}
}).catch((err) => {
console.info('promise failed');
......@@ -2195,16 +2195,16 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
**返回值:**
```
```js
sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) {
if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x);
for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i])
console.info("data[" + i + "]: " + data[i])
}
})
```
......@@ -2233,15 +2233,15 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
**返回值:**
```
```js
const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
promise.then((data) => {
console.info(LABEL + 'createRotationMatrix_promise successed');
console.info('createRotationMatrix_promise successed');
for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]);
}
}).catch((err) => {
console.info(LABEL + 'promise failed');
console.info('promise failed');
})
```
......@@ -2356,7 +2356,7 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ----- | ------ | ---- | ---- | ------------------------ |
| ----- | ------ | ---- | ---- | ----------------- |
| alpha | number | 是 | 是 | 设备围绕Z轴的旋转角度,单位:度。 |
| beta | number | 是 | 是 | 设备围绕X轴的旋转角度,单位:度。 |
| gamma | number | 是 | 是 | 设备围绕Y轴的旋转角度,单位:度。 |
......
......@@ -521,7 +521,7 @@ getMaxSimCount\(\): number
**示例:**
```js
console.log(sim.getMaxSimCount())
console.log("Result: "+ sim.getMaxSimCount())
```
......
......@@ -281,7 +281,7 @@ popFirst(): T
| -------- | -------- |
| T | 返回删除的数据。 |
**返回值:**
**示例:**
```ts
let treeSet = new TreeSet();
......@@ -305,7 +305,7 @@ popLast(): T
| -------- | -------- |
| T | 返回删除的数据。 |
**返回值:**
**示例:**
```ts
let treeSet = new TreeSet();
......
......@@ -6,7 +6,7 @@
## 导入模块
```
```js
import uri from '@ohos.uri'
```
......@@ -14,7 +14,7 @@ import uri from '@ohos.uri'
### 属性
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Utils.Lang
**系统能力:** SystemCapability.Utils.Lang
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
......@@ -41,7 +41,7 @@ constructor是URI的构造函数。
| 参数名 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| url | string | 是 | 是 | 入参对象。 |
| uri | string | 是 | 是 | 入参对象。 |
**示例:**
......@@ -71,7 +71,7 @@ toString(): string
**示例:**
```js
const url = new uri.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
const url = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toString()
```
......
# 振动
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
```js
import vibrator from '@ohos.vibrator';
```
......@@ -34,7 +35,7 @@ vibrate(duration: number): Promise&lt;void&gt;
**示例:**
```
```js
vibrator.vibrate(1000).then(()=>{
console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{
......@@ -60,7 +61,7 @@ vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 |
**示例:**
```
```js
vibrator.vibrate(1000,function(error){
if(error){
console.log("error.code"+error.code+"error.message"+error.message);
......@@ -92,7 +93,7 @@ vibrate(effectId: EffectId): Promise&lt;void&gt;
| Promise&lt;void&gt; | 指示触发振动是否成功。 |
**示例:**
```
```js
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{
console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{
......@@ -118,7 +119,7 @@ vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 |
**示例:**
```
```js
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){
if(error){
console.log("error.code"+error.code+"error.message"+error.message);
......@@ -150,7 +151,7 @@ stop(stopMode: VibratorStopMode): Promise&lt;void&gt;
| Promise&lt;void&gt; | 指示停止振动是否成功。 |
**示例:**
```
```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{
console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{
......@@ -176,7 +177,7 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void;
| callback | AsyncCallback&lt;void&gt; | 否 | 马达停止振动的回调函数,指示停止振动是否成功。 |
**示例:**
```
```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){
if(error){
console.log("error.code"+error.code+"error.message"+error.message);
......
......@@ -993,7 +993,7 @@ getOperationType(agent: WantAgent): Promise\<number>;
| 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number> | 以Promise形式返回获取optionType的结果。 |
| Promise\<number> | 以Promise形式返回获取operationType的结果。 |
**示例:**
......
......@@ -23,7 +23,7 @@ import webSocket from '@ohos.net.webSocket';
var defaultIpAddress = "ws://";
let ws = webSocket.createWebSocket();
ws.on('open', (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
console.log("on open, status:" + value['status'] + ", message:" + value['message']);
// 当收到on('open')事件时,可以通过send()方法与服务器进行通信
ws.send("Hello, server!", (err, value) => {
if (!err) {
......@@ -393,7 +393,7 @@ on\(type: 'open', callback: AsyncCallback<Object\>\): void
```js
let ws = webSocket.createWebSocket();
ws.on('open', (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
console.log("on open, status:" + value['status'] + ", message:" + value['message']);
});
```
......@@ -421,7 +421,7 @@ off\(type: 'open', callback?: AsyncCallback<Object\>\): void
```js
let ws = webSocket.createWebSocket();
let callback1 = (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
console.log("on open, status:" + value['status'] + ", message:" + value['message']);
}
ws.on('open', callback1);
// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅
......
......@@ -12,7 +12,8 @@ WebGL标准图形API,对应OpenGL ES 2.0特性集。更多信息请参考[WebG
hml内创建canvas,示例如下:
```
```html
<!--xxx.hml-->
<div class="container">
<canvas ref="canvas1" style="width : 400px; height : 200px; background-color : lightyellow;"></canvas>
<button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button>
......
......@@ -12,7 +12,8 @@ WebGL标准图形API,对应OpenGL ES 3.0特性集。更多信息请参考[WebG
hml内创建canvas,示例如下:
```
```html
<!--xxx.hml-->
<div class="container">
<canvas ref="canvas1" style="width : 400px; height : 200px; background-color : lightyellow;"></canvas>
<button class="btn-button" onclick="BtnDraw2D">BtnDraw2D</button>
......
......@@ -137,7 +137,7 @@ setData(key: string, value: object): boolean
| 参数名 | 参数类型 | 必填 | 描述 |
| ----- | ------ | ---- | ------- |
| key | string | 是 | 数据值。 |
| key | string | 是 | 数据值。 |
| value | object | 是 | 要存储的数据。 |
**返回值:**
......@@ -170,7 +170,7 @@ getData(key: string): object
| 参数名 | 参数类型 | 必填 | 描述 |
| ---- | ------ | ---- | ----- |
| key | string | 是 | 数据值。 |
| key | string | 是 | 数据值。 |
**返回值:**
| 类型 | 说明 |
......@@ -201,7 +201,7 @@ clearData(key?: string): boolean
| 参数名 | 参数类型 | 必填 | 描述 |
| ---- | ------ | ---- | ----- |
| key | string | 否 | 数据值。 |
| key | string | 否 | 数据值。 |
**返回值:**
| 类型 | 说明 |
......@@ -225,14 +225,14 @@ setDragImage(pixelmap: PixelMap, offsetX: number,offsetY: number): boolean
| 参数名 | 参数类型 | 必填 | 描述 |
| -------- | -------- | ---- | ---------------------------------------- |
| pixelmap | PixelMap | 是 | pixelmap为前端传入的图片资源,请参考[PixelMap对象](../apis/js-apis-image.md#pixelmap7)。 |
| pixelmap | [PixelMap](../apis/js-apis-image.md#pixelmap7) | 是 | 前端传入的图片资源。 |
| offsetX | number | 是 | 相对于图片的横向偏移量。 |
| offsetY | number | 是 | 相对于图片的纵向偏移量 。 |
| offsetY | number | 是 | 相对于图片的纵向偏移量。 |
**返回值:**
| 类型 | 说明 |
| ---- | ------------------------ |
| bool | 执行结果,true表示成功,false表示失败。 |
| boolean | 执行结果,true表示成功,false表示失败。 |
**示例:**
......
......@@ -39,13 +39,24 @@ List(value:{space?: number, initialIndex?: number})
| chainAnimation | boolean | false | 用于设置当前list是否启用链式联动动效,开启后列表滑动以及顶部和底部拖拽时会有链式联动的效果。链式联动效果:list内的list-item间隔一定距离,在基本的滑动交互行为下,主动对象驱动从动对象进行联动,驱动效果遵循弹簧物理动效。<br/>-&nbsp;false:不启用链式联动。<br/>-&nbsp;true:启用链式联动。 |
| multiSelectable<sup>8+</sup> | boolean | false | 是否开启鼠标框选。<br/>-&nbsp;false:关闭框选。<br/>-&nbsp;true:开启框选。 |
| restoreId<sup>8+</sup> | number | - | 组件迁移标识符,标识后的组件在应用迁移时,组件状态会被迁移到被拉起方的同标识组件。<br/>列表组件状态,包括起始位置显示的item序号。 |
| lanes<sup>9+</sup> | number \|<br>{<br/>minLength: Length,<br/>maxLength: Length<br/>} | 1 | 以列模式为例(listDirection为Axis.Vertical):<br/>lanes用于决定List组件在交叉轴方向按几列布局,规则如下:<br/>- lanes为指定的数量时,根据指定的数量与List组件的交叉轴宽度来决定每列的宽度;<br/>- lane设置了{minLength,maxLength}时,根据List组件的宽度自适应决定lanes数量(即列数),保证缩放过程中lane的宽度符合{minLength,maxLength}的限制。其中,minLength条件会被优先满足,即优先保证符合ListItem的宽度符合最小宽度限制。例如在列模式下,设置了{minLength: 40vp,maxLength: 60vp},则当List组件宽度为70vp时,ListItem为一列,并且根据alignListItem属性做靠左、居中或者靠右布局;当List组件宽度变化至80vp时,符合两倍的minLength,则ListItem自适应为两列。 |
| alignListItem<sup>9+</sup> | ListItemAlign | ListItemAlign.Center | List交叉轴方向宽度大于ListItem交叉轴宽度 * lanes时,ListItem在List交叉轴方向的布局方式,默认为居中。 |
- EdgeEffect枚举说明
| 名称 | 描述 |
| -------- | -------- |
| ------ | ------------------------------------------------------------ |
| Spring | 弹性物理动效,滑动到边缘后可以根据初始速度或通过触摸事件继续滑动一段距离,松手后回弹。 |
| None | 滑动到边缘后无效果。 |
- ListItemAlign枚举说明
| 名称 | 描述 |
| ------ | -------------------------------------- |
| Start | ListItem在List中,交叉轴方向首部对齐。 |
| Center | ListItem在List中,交叉轴方向居中对齐。 |
| End | ListItem在List中,交叉轴方向尾部对齐。 |
## 事件
......@@ -120,3 +131,49 @@ struct ListExample {
```
![zh-cn_image_0000001174264378](figures/zh-cn_image_0000001174264378.gif)
```ts
// xxx.ets
@Entry
@Component
struct ListLanesExample {
@State arr: string[] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"]
@State alignListItem: ListItemAlign = ListItemAlign.Start
build() {
Column() {
List({ space: 20, initialIndex: 0 }) {
ForEach(this.arr, (item) => {
ListItem() {
Text('' + item)
.width('100%')
.height(100)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xFFFFFF)
}
.border({ width: 2, color: Color.Green })
}, item => item)
}
.height(300)
.width("90%")
.editMode(true)
.border({ width: 3, color: Color.Red })
.lanes({ minLength: 40, maxLength: 60 })
.alignListItem(this.alignListItem)
Button("点击更改alignListItem:" + this.alignListItem).onClick(() => {
if (this.alignListItem == ListItemAlign.Start) {
this.alignListItem = ListItemAlign.Center
} else if (this.alignListItem == ListItemAlign.Center) {
this.alignListItem = ListItemAlign.End
} else {
this.alignListItem = ListItemAlign.Start
}
})
}.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 })
}
}
```
......@@ -14,6 +14,7 @@
| **名称** | **参数类型** | **默认值** | **描述** |
| -------- | -------- | -------- | -------- |
| focusable | boolean | false | 设置当前组件是否可以获焦。 |
| tabIndex<sup>9+<sup> | number | 0 | 自定义组件tab键走焦能力,走焦顺序为:tabIndex大于0的组件依次递增走焦, tabIndex等于0的组件按组件树先后顺序走焦。<br />- tabIndex >= 0:表示元素是可聚焦的,并且可以通过tab键走焦来访问到该元素,按照tabIndex的数值递增而先后获焦。如果多个元素拥有相同的tabIndex,按照元素在当前组件树中的先后顺序获焦<br />- tabIndex < 0(通常是tabIndex = -1):表示元素是可聚焦的,但是不能通过tab键走焦来访问到该元素 |
> **说明:**
> 支持焦点控制的组件:Button、Text、Image、List、Grid。
......@@ -26,51 +27,41 @@
@Entry
@Component
struct FocusableExample {
@State textOne: string = ''
@State textTwo: string = ''
@State textThree: string = 'The third button cannot be focused'
@State oneButtonColor: string = '#FF0000'
@State twoButtonColor: string = '#FFC0CB'
@State threeButtonColor: string = '#87CEFA'
@State text1: string = 'TabIndex=3'
@State text2: string = 'TabIndex=2'
@State text3: string = 'focusable=false'
@State text4: string = 'TabIndex=-1'
@State text5: string = 'TabIndex=1'
@State text6: string = 'TabIndex=1'
@State text7: string = 'focusable=true'
@State text8: string = 'focusable=true'
build() {
Column({ space:20 }){
Button(this.textOne)
.backgroundColor(this.oneButtonColor)
Button(this.text1) // 按下TAB键第四个获焦的组件
.width(300).height(70).fontColor(Color.Black)
.focusable(true)
.onFocus(() => {
this.textOne = 'First Button onFocus'
this.oneButtonColor = '#AFEEEE'
})
.onBlur(() => {
this.textOne = 'First Button onBlur'
this.oneButtonColor = '#FFC0CB'
})
Button(this.textTwo)
.backgroundColor(this.twoButtonColor)
.tabIndex(3)
Button(this.text2) // 按下TAB键第三个获焦的组件
.width(300).height(70).fontColor(Color.Black)
.focusable(true)
.onFocus(() => {
this.textTwo = 'Second Button onFocus'
this.twoButtonColor = '#AFEEEE'
})
.onBlur(() => {
this.textTwo = 'Second Button onBlur'
this.twoButtonColor = '#FFC0CB'
})
Button(this.textThree)
.backgroundColor(this.threeButtonColor)
.tabIndex(2)
Button(this.text3) // 无法获焦的组件
.width(300).height(70).fontColor(Color.Black)
.focusable(false)
.onFocus(() => {
this.textThree = 'Third Button onFocus'
this.threeButtonColor = '#AFEEEE'
})
.onBlur(() => {
this.textThree = 'Third Button onBlur'
this.threeButtonColor = '#FFC0CB'
})
Button(this.text4) // 无法使用TAB键,但可以使用方向键走焦的组件
.width(300).height(70).fontColor(Color.Black)
.tabIndex(-1)
Button(this.text5) // 按下TAB键第一个获焦的组件
.width(300).height(70).fontColor(Color.Black)
.tabIndex(1)
Button(this.text6) // 按下TAB键第二个获焦的组件
.width(300).height(70).fontColor(Color.Black)
.tabIndex(1)
Button(this.text7) // 按下TAB键第五个获焦的组件
.width(300).height(70).fontColor(Color.Black)
.focusable(true)
Button(this.text8) // 按下TAB键第六个获焦的组件
.width(300).height(70).fontColor(Color.Black)
.focusable(true)
}.width('100%').margin({ top:20 })
}
}
......
......@@ -14,6 +14,8 @@
| 标准C++库 | [libc++](https://libcxx.llvm.org/) 是C++标准库的一种实现。 |
| OpenSL ES | [OpenSL ES](https://www.khronos.org/registry/OpenSL-ES/)是一个嵌入式跨平台的音频处理库。 |
| zlib | [Zlib](https://zlib.net/)是基于C/C++语言实现的一个通用的数据压缩库。 |
| EGL | [EGL](https://www.khronos.org/egl/)是渲染API与底层原生窗口系统之间的一种标准的软件接口。 |
| OpenGL ES | [OpenGL ES](https://www.khronos.org/opengles/)是一个嵌入式跨平台的为 3D 图形处理硬件指定标准的软件接口。 |
## 标准C库
......@@ -71,3 +73,27 @@ C++11、C++14标准已完全支持,C++17和C++20标准正在完善。
## EGL
EGL 是Khronos渲染API (如OpenGL ES 或 OpenVG) 与底层原生窗口系统之间的接口。OpenHarmony 现已支持 EGL。
**标准库中导出的符号列表**
[native api中导出的EGL符号列表](../third_party_opengl/egl-symbol.md)
## OpenGL ES
OpenGL 是一种跨平台的图形 API,用于为 3D 图形处理硬件指定标准的软件接口。[OpenGL ES](https://www.khronos.org/opengles/) 是 OpenGL 规范的一种形式,适用于嵌入式设备。OpenHarmony 现已支持 OpenGL ES 3.0。
**支持的能力**
OpenGL ES 3.0
**标准库中导出的符号列表**
[native api中导出的OpenGL ES 3.0符号列表](../third_party_opengl/openglesv3-symbol.md)
**native api中导出的EGL符号列表**
|符号类型|符号名|备注|
| --- | --- | --- |
|FUNC|eglChooseConfig||
|FUNC|eglCopyBuffers||
|FUNC|eglCreateContext||
|FUNC|eglCreatePbufferSurface||
|FUNC|eglCreatePixmapSurface||
|FUNC|eglCreateWindowSurface||
|FUNC|eglDestroyContext||
|FUNC|eglDestroySurface||
|FUNC|eglGetConfigAttrib||
|FUNC|eglGetConfigs||
|FUNC|eglGetCurrentDisplay||
|FUNC|eglGetCurrentSurface||
|FUNC|eglGetDisplay||
|FUNC|eglGetError||
|FUNC|eglGetProcAddress||
|FUNC|eglInitialize||
|FUNC|eglMakeCurrent||
|FUNC|eglQueryContext||
|FUNC|eglQueryString||
|FUNC|eglQuerySurface||
|FUNC|eglSwapBuffers||
|FUNC|eglTerminate||
|FUNC|eglWaitGL||
|FUNC|eglWaitNative||
|FUNC|eglBindTexImage||
|FUNC|eglReleaseTexImage||
|FUNC|eglSurfaceAttrib||
|FUNC|eglSwapInterval||
|FUNC|eglBindAPI||
|FUNC|eglQueryAPI||
|FUNC|eglCreatePbufferFromClientBuffer||
|FUNC|eglReleaseThread||
|FUNC|eglWaitClient||
|FUNC|eglGetCurrentContext||
|FUNC|eglCreateSync||
|FUNC|eglDestroySync||
|FUNC|eglClientWaitSync||
|FUNC|eglGetSyncAttrib||
|FUNC|eglCreateImage||
|FUNC|eglDestroyImage||
|FUNC|eglGetPlatformDisplay||
|FUNC|eglCreatePlatformWindowSurface||
|FUNC|eglCreatePlatformPixmapSurface||
|FUNC|eglWaitSync||
**native api中导出的OpenGL ES 3.0符号列表**
|符号类型|符号名|备注|
| --- | --- | --- |
|FUNC|glActiveShaderProgram||
|FUNC|glActiveTexture||
|FUNC|glAttachShader||
|FUNC|glBeginQuery||
|FUNC|glBeginTransformFeedback||
|FUNC|glBindAttribLocation||
|FUNC|glBindBuffer||
|FUNC|glBindBufferBase||
|FUNC|glBindBufferRange||
|FUNC|glBindFramebuffer||
|FUNC|glBindImageTexture||
|FUNC|glBindProgramPipeline||
|FUNC|glBindRenderbuffer||
|FUNC|glBindSampler||
|FUNC|glBindTexture||
|FUNC|glBindTransformFeedback||
|FUNC|glBindVertexArray||
|FUNC|glBindVertexBuffer||
|FUNC|glBlendBarrier||
|FUNC|glBlendColor||
|FUNC|glBlendEquation||
|FUNC|glBlendEquationi||
|FUNC|glBlendEquationSeparate||
|FUNC|glBlendEquationSeparatei||
|FUNC|glBlendFunc||
|FUNC|glBlendFunci||
|FUNC|glBlendFuncSeparate||
|FUNC|glBlendFuncSeparatei||
|FUNC|glBlitFramebuffer||
|FUNC|glBufferData||
|FUNC|glBufferSubData||
|FUNC|glCheckFramebufferStatus||
|FUNC|glClear||
|FUNC|glClearBufferfi||
|FUNC|glClearBufferfv||
|FUNC|glClearBufferiv||
|FUNC|glClearBufferuiv||
|FUNC|glClearColor||
|FUNC|glClearDepthf||
|FUNC|glClearStencil||
|FUNC|glClientWaitSync||
|FUNC|glColorMask||
|FUNC|glColorMaski||
|FUNC|glCompileShader||
|FUNC|glCompressedTexImage2D||
|FUNC|glCompressedTexImage3D||
|FUNC|glCompressedTexSubImage2D||
|FUNC|glCompressedTexSubImage3D||
|FUNC|glCopyBufferSubData||
|FUNC|glCopyImageSubData||
|FUNC|glCopyTexImage2D||
|FUNC|glCopyTexSubImage2D||
|FUNC|glCopyTexSubImage3D||
|FUNC|glCreateProgram||
|FUNC|glCreateShader||
|FUNC|glCreateShaderProgramv||
|FUNC|glCullFace||
|FUNC|glDebugMessageCallback||
|FUNC|glDebugMessageControl||
|FUNC|glDebugMessageInsert||
|FUNC|glDeleteBuffers||
|FUNC|glDeleteFramebuffers||
|FUNC|glDeleteProgram||
|FUNC|glDeleteProgramPipelines||
|FUNC|glDeleteQueries||
|FUNC|glDeleteRenderbuffers||
|FUNC|glDeleteSamplers||
|FUNC|glDeleteShader||
|FUNC|glDeleteSync||
|FUNC|glDeleteTextures||
|FUNC|glDeleteTransformFeedbacks||
|FUNC|glDeleteVertexArrays||
|FUNC|glDepthFunc||
|FUNC|glDepthMask||
|FUNC|glDepthRangef||
|FUNC|glDetachShader||
|FUNC|glDisable||
|FUNC|glDisablei||
|FUNC|glDisableVertexAttribArray||
|FUNC|glDispatchCompute||
|FUNC|glDispatchComputeIndirect||
|FUNC|glDrawArrays||
|FUNC|glDrawArraysIndirect||
|FUNC|glDrawArraysInstanced||
|FUNC|glDrawBuffers||
|FUNC|glDrawElements||
|FUNC|glDrawElementsBaseVertex||
|FUNC|glDrawElementsIndirect||
|FUNC|glDrawElementsInstanced||
|FUNC|glDrawElementsInstancedBaseVertex||
|FUNC|glDrawRangeElements||
|FUNC|glDrawRangeElementsBaseVertex||
|FUNC|glEnable||
|FUNC|glEnablei||
|FUNC|glEnableVertexAttribArray||
|FUNC|glEndQuery||
|FUNC|glEndTransformFeedback||
|FUNC|glFenceSync||
|FUNC|glFinish||
|FUNC|glFlush||
|FUNC|glFlushMappedBufferRange||
|FUNC|glFramebufferParameteri||
|FUNC|glFramebufferRenderbuffer||
|FUNC|glFramebufferTexture||
|FUNC|glFramebufferTexture2D||
|FUNC|glFramebufferTextureLayer||
|FUNC|glFrontFace||
|FUNC|glGenBuffers||
|FUNC|glGenerateMipmap||
|FUNC|glGenFramebuffers||
|FUNC|glGenProgramPipelines||
|FUNC|glGenQueries||
|FUNC|glGenRenderbuffers||
|FUNC|glGenSamplers||
|FUNC|glGenTextures||
|FUNC|glGenTransformFeedbacks||
|FUNC|glGenVertexArrays||
|FUNC|glGetActiveAttrib||
|FUNC|glGetActiveUniform||
|FUNC|glGetActiveUniformBlockiv||
|FUNC|glGetActiveUniformBlockName||
|FUNC|glGetActiveUniformsiv||
|FUNC|glGetAttachedShaders||
|FUNC|glGetAttribLocation||
|FUNC|glGetBooleani_v||
|FUNC|glGetBooleanv||
|FUNC|glGetBufferParameteri64v||
|FUNC|glGetBufferParameteriv||
|FUNC|glGetBufferPointerv||
|FUNC|glGetDebugMessageLog||
|FUNC|glGetError||
|FUNC|glGetFloatv||
|FUNC|glGetFragDataLocation||
|FUNC|glGetFramebufferAttachmentParameteriv||
|FUNC|glGetFramebufferParameteriv||
|FUNC|glGetGraphicsResetStatus||
|FUNC|glGetInteger64i_v||
|FUNC|glGetInteger64v||
|FUNC|glGetIntegeri_v||
|FUNC|glGetIntegerv||
|FUNC|glGetInternalformativ||
|FUNC|glGetMultisamplefv||
|FUNC|glGetnUniformfv||
|FUNC|glGetnUniformiv||
|FUNC|glGetnUniformuiv||
|FUNC|glGetObjectLabel||
|FUNC|glGetObjectPtrLabel||
|FUNC|glGetPointerv||
|FUNC|glGetProgramBinary||
|FUNC|glGetProgramInfoLog||
|FUNC|glGetProgramInterfaceiv||
|FUNC|glGetProgramiv||
|FUNC|glGetProgramPipelineInfoLog||
|FUNC|glGetProgramPipelineiv||
|FUNC|glGetProgramResourceIndex||
|FUNC|glGetProgramResourceiv||
|FUNC|glGetProgramResourceLocation||
|FUNC|glGetProgramResourceName||
|FUNC|glGetQueryiv||
|FUNC|glGetQueryObjectuiv||
|FUNC|glGetRenderbufferParameteriv||
|FUNC|glGetSamplerParameterfv||
|FUNC|glGetSamplerParameterIiv||
|FUNC|glGetSamplerParameterIuiv||
|FUNC|glGetSamplerParameteriv||
|FUNC|glGetShaderInfoLog||
|FUNC|glGetShaderiv||
|FUNC|glGetShaderPrecisionFormat||
|FUNC|glGetShaderSource||
|FUNC|glGetString||
|FUNC|glGetStringi||
|FUNC|glGetSynciv||
|FUNC|glGetTexLevelParameterfv||
|FUNC|glGetTexLevelParameteriv||
|FUNC|glGetTexParameterfv||
|FUNC|glGetTexParameterIiv||
|FUNC|glGetTexParameterIuiv||
|FUNC|glGetTexParameteriv||
|FUNC|glGetTransformFeedbackVarying||
|FUNC|glGetUniformBlockIndex||
|FUNC|glGetUniformfv||
|FUNC|glGetUniformIndices||
|FUNC|glGetUniformiv||
|FUNC|glGetUniformLocation||
|FUNC|glGetUniformuiv||
|FUNC|glGetVertexAttribfv||
|FUNC|glGetVertexAttribIiv||
|FUNC|glGetVertexAttribIuiv||
|FUNC|glGetVertexAttribiv||
|FUNC|glGetVertexAttribPointerv||
|FUNC|glHint||
|FUNC|glInvalidateFramebuffer||
|FUNC|glInvalidateSubFramebuffer||
|FUNC|glIsBuffer||
|FUNC|glIsEnabled||
|FUNC|glIsEnabledi||
|FUNC|glIsFramebuffer||
|FUNC|glIsProgram||
|FUNC|glIsProgramPipeline||
|FUNC|glIsQuery||
|FUNC|glIsRenderbuffer||
|FUNC|glIsSampler||
|FUNC|glIsShader||
|FUNC|glIsSync||
|FUNC|glIsTexture||
|FUNC|glIsTransformFeedback||
|FUNC|glIsVertexArray||
|FUNC|glLineWidth||
|FUNC|glLinkProgram||
|FUNC|glMapBufferRange||
|FUNC|glMemoryBarrier||
|FUNC|glMemoryBarrierByRegion||
|FUNC|glMinSampleShading||
|FUNC|glObjectLabel||
|FUNC|glObjectPtrLabel||
|FUNC|glPatchParameteri||
|FUNC|glPauseTransformFeedback||
|FUNC|glPixelStorei||
|FUNC|glPolygonOffset||
|FUNC|glPopDebugGroup||
|FUNC|glPrimitiveBoundingBox||
|FUNC|glProgramBinary||
|FUNC|glProgramParameteri||
|FUNC|glProgramUniform1f||
|FUNC|glProgramUniform1fv||
|FUNC|glProgramUniform1i||
|FUNC|glProgramUniform1iv||
|FUNC|glProgramUniform1ui||
|FUNC|glProgramUniform1uiv||
|FUNC|glProgramUniform2f||
|FUNC|glProgramUniform2fv||
|FUNC|glProgramUniform2i||
|FUNC|glProgramUniform2iv||
|FUNC|glProgramUniform2ui||
|FUNC|glProgramUniform2uiv||
|FUNC|glProgramUniform3f||
|FUNC|glProgramUniform3fv||
|FUNC|glProgramUniform3i||
|FUNC|glProgramUniform3iv||
|FUNC|glProgramUniform3ui||
|FUNC|glProgramUniform3uiv||
|FUNC|glProgramUniform4f||
|FUNC|glProgramUniform4fv||
|FUNC|glProgramUniform4i||
|FUNC|glProgramUniform4iv||
|FUNC|glProgramUniform4ui||
|FUNC|glProgramUniform4uiv||
|FUNC|glProgramUniformMatrix2fv||
|FUNC|glProgramUniformMatrix2x3fv||
|FUNC|glProgramUniformMatrix2x4fv||
|FUNC|glProgramUniformMatrix3fv||
|FUNC|glProgramUniformMatrix3x2fv||
|FUNC|glProgramUniformMatrix3x4fv||
|FUNC|glProgramUniformMatrix4fv||
|FUNC|glProgramUniformMatrix4x2fv||
|FUNC|glProgramUniformMatrix4x3fv||
|FUNC|glPushDebugGroup||
|FUNC|glReadBuffer||
|FUNC|glReadnPixels||
|FUNC|glReadPixels||
|FUNC|glReleaseShaderCompiler||
|FUNC|glRenderbufferStorage||
|FUNC|glRenderbufferStorageMultisample||
|FUNC|glResumeTransformFeedback||
|FUNC|glSampleCoverage||
|FUNC|glSampleMaski||
|FUNC|glSamplerParameterf||
|FUNC|glSamplerParameterfv||
|FUNC|glSamplerParameteri||
|FUNC|glSamplerParameterIiv||
|FUNC|glSamplerParameterIuiv||
|FUNC|glSamplerParameteriv||
|FUNC|glScissor||
|FUNC|glShaderBinary||
|FUNC|glShaderSource||
|FUNC|glStencilFunc||
|FUNC|glStencilFuncSeparate||
|FUNC|glStencilMask||
|FUNC|glStencilMaskSeparate||
|FUNC|glStencilOp||
|FUNC|glStencilOpSeparate||
|FUNC|glTexBuffer||
|FUNC|glTexBufferRange||
|FUNC|glTexImage2D||
|FUNC|glTexImage3D||
|FUNC|glTexParameterf||
|FUNC|glTexParameterfv||
|FUNC|glTexParameteri||
|FUNC|glTexParameterIiv||
|FUNC|glTexParameterIuiv||
|FUNC|glTexParameteriv||
|FUNC|glTexStorage2D||
|FUNC|glTexStorage2DMultisample||
|FUNC|glTexStorage3D||
|FUNC|glTexStorage3DMultisample||
|FUNC|glTexSubImage2D||
|FUNC|glTexSubImage3D||
|FUNC|glTransformFeedbackVaryings||
|FUNC|glUniform1f||
|FUNC|glUniform1fv||
|FUNC|glUniform1i||
|FUNC|glUniform1iv||
|FUNC|glUniform1ui||
|FUNC|glUniform1uiv||
|FUNC|glUniform2f||
|FUNC|glUniform2fv||
|FUNC|glUniform2i||
|FUNC|glUniform2iv||
|FUNC|glUniform2ui||
|FUNC|glUniform2uiv||
|FUNC|glUniform3f||
|FUNC|glUniform3fv||
|FUNC|glUniform3i||
|FUNC|glUniform3iv||
|FUNC|glUniform3ui||
|FUNC|glUniform3uiv||
|FUNC|glUniform4f||
|FUNC|glUniform4fv||
|FUNC|glUniform4i||
|FUNC|glUniform4iv||
|FUNC|glUniform4ui||
|FUNC|glUniform4uiv||
|FUNC|glUniformBlockBinding||
|FUNC|glUniformMatrix2fv||
|FUNC|glUniformMatrix2x3fv||
|FUNC|glUniformMatrix2x4fv||
|FUNC|glUniformMatrix3fv||
|FUNC|glUniformMatrix3x2fv||
|FUNC|glUniformMatrix3x4fv||
|FUNC|glUniformMatrix4fv||
|FUNC|glUniformMatrix4x2fv||
|FUNC|glUniformMatrix4x3fv||
|FUNC|glUnmapBuffer||
|FUNC|glUseProgram||
|FUNC|glUseProgramStages||
|FUNC|glValidateProgram||
|FUNC|glValidateProgramPipeline||
|FUNC|glVertexAttrib1f||
|FUNC|glVertexAttrib1fv||
|FUNC|glVertexAttrib2f||
|FUNC|glVertexAttrib2fv||
|FUNC|glVertexAttrib3f||
|FUNC|glVertexAttrib3fv||
|FUNC|glVertexAttrib4f||
|FUNC|glVertexAttrib4fv||
|FUNC|glVertexAttribBinding||
|FUNC|glVertexAttribDivisor||
|FUNC|glVertexAttribFormat||
|FUNC|glVertexAttribI4i||
|FUNC|glVertexAttribI4iv||
|FUNC|glVertexAttribI4ui||
|FUNC|glVertexAttribI4uiv||
|FUNC|glVertexAttribIFormat||
|FUNC|glVertexAttribIPointer||
|FUNC|glVertexAttribPointer||
|FUNC|glVertexBindingDivisor||
|FUNC|glViewport||
|FUNC|glWaitSync||
......@@ -129,3 +129,4 @@
| ohos.permission.GET_DEFAULT_APPLICATION | system_core | system_grant | TRUE | 允许应用查询默认应用。 |
| ohos.permission.SET_DEFAULT_APPLICATION | system_core | system_grant | TRUE | 允许应用设置、重置默认应用。 |
| ohos.permission.MANAGE_DISPOSED_APP_STATUS | system_core | system_grant | TRUE | 允许设置和查询应用的处置状态。 |
| ohos.permission.ACCESS_IDS | system_core | system_grant | TRUE | 允许应用查询设备的唯一标识符信息。 |
\ No newline at end of file
......@@ -261,7 +261,7 @@ int32_t CodecDaiHwParams(const struct AudioCard *card, const struct AudioPcmHwPa
unsigned int bitWidth;
struct CodecDaiParamsVal codecDaiParamsVal;
...
int ret = AudioFramatToBitWidth(param->format, &bitWidth);
int ret = AudioFormatToBitWidth(param->format, &bitWidth);
...
codecDaiParamsVal.frequencyVal = param->rate;
codecDaiParamsVal.formatVal = bitWidth;
......@@ -1019,7 +1019,7 @@ int32_t DaiHwParams(const struct AudioCard *card, const struct AudioPcmHwParams
struct DaiData *data = DaiDataFromCard(card);
data->pcmInfo.channels = param->channels;
...
AudioFramatToBitWidth(param->format, &bitWidth);
AudioFormatToBitWidth(param->format, &bitWidth);
...
data->pcmInfo.bitWidth = bitWidth;
data->pcmInfo.rate = param->rate;
......
......@@ -39,11 +39,11 @@
用户身份认证处理需要保证用户数据安全以及认证结果的准确性,用户认证框架与基础认证服务间的关键交互信息需要做数据完整性保护,各基础认证服务将提供的执行器能力对接到用户认证框架时,需要交换各自的公钥,其中:
1)执行器通过用户认证框架公钥校验调度指令的准确性,例如一个口令模板被锁定后,相关口令认证能力无法使用。由于口令认证属于敏感操作,此时需要通过校验来确保调度指令的准确性后,方可进行后续解锁操作。
1)执行器通过用户认证框架公钥校验调度指令的准确性,例如一个人脸模板被锁定后,相关人脸认证能力无法使用。由于人脸认证属于敏感操作,此时需要通过校验来确保调度指令的准确性后,方可进行后续解锁操作。
2)执行器公钥可被用户认证框架用于校验认证结果的准确性,同时用于执行器交互认证时的校验交互信息的完整性。
- 口令认证凭据模板
- 人脸认证凭据模板
认证凭据是在用户设置认证凭据时由认证服务产生并存储,每个模板有一个ID,用于索引模板信息文件,在认证时读取模板信息并用于与当次认证过程中产生的认证数据做对比,完成身份认证。
......@@ -161,7 +161,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
IAM_LOGI("start");
auto *hdfFaceAuthInterfaceHost = new (std::nothrow) HdfFaceAuthInterfaceHost;
if (hdfFaceAuthInterfaceHost == nullptr) {
IAM_LOGE("%{public}s: failed to create create HdfFaceAuthInterfaceHost object", __func__);
IAM_LOGE("%{public}s: failed to create HdfFaceAuthInterfaceHost object", __func__);
return HDF_FAILURE;
}
......@@ -171,7 +171,7 @@ Face_auth驱动的主要工作是为上层用户认证框架和Face_auth服务
auto serviceImpl = IFaceAuthInterface::Get(true);
if (serviceImpl == nullptr) {
IAM_LOGE("%{public}s: failed to get of implement service", __func__);
IAM_LOGE("%{public}s: failed to implement service", __func__);
return HDF_FAILURE;
}
......
......@@ -69,7 +69,7 @@ Sensor驱动模型对外开放的API接口能力的具体实现请参考:
| int32_t GetAllSensors(struct SensorInformation **sensorInfo, int32_t *count) | 获取系统中注册的所有传感器信息,一组完整传感器信息包括传感器名字、设备厂商、固件版本号、硬件版本号、传感器类型编号、传感器标识、最大量程、精度、功耗。 |
| int32_t Enable(int32_t sensorId) | 使能指定传感器设备,只有数据订阅者使能传感器后,才能获取订阅的传感器数据。 |
| int32_t Disable(int32_t sensorId) | 去使能指定传感器设备。 |
| int32_t SetBatch(iint32_t sensorId, int64_t samplingInterval, int64_t reportInterval) | 设置指定传感器的数据采样间隔和数据上报间隔。 |
| int32_t SetBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval) | 设置指定传感器的数据采样间隔和数据上报间隔。 |
| int32_t SetMode(int32_t sensorId, int32_t mode) | 设置指定传感器的工作模式,不同的工作模式,上报数据方式不同。 |
| int32_t SetOption(int32_t sensorId, uint32_t option) | 设置指定传感器量程,精度等可选配置。 |
| int32_t Register(int32_t groupId, RecordDataCallback cb) | 订阅者根据不同groupId注册传感器数据回调函数,系统会将获取到的传感器数据上报给订阅者。 |
......@@ -577,7 +577,7 @@ HWTEST_F(HdfSensorTest,TestAccelDriver_001, TestSize.Level0)
}
/* 打印获取的传感器列表 */
for (int i = 0; i < count; i++) {
printf("get sensoriId[%d], info name[%s]\n\r", sensorInfo[i]->sensorId, sensorInfo[i]->sensorName);
printf("get sensorId[%d], info name[%s]\n\r", sensorInfo[i]->sensorId, sensorInfo[i]->sensorName);
}
ret = g_sensorDev->Enable(accelSensorId);
EXPECT_EQ(0, ret);
......
......@@ -221,7 +221,7 @@ MIPI DSI模块适配的三个环节是配置属性文件,实例化驱动入口
函数说明:
该函数需要在驱动入口结构体中赋值给Release接口,当DF框架调用Init函数初始化驱动失败时,可以调用Release释放驱动资源,该函数中需包含释放内存和删除控制器等操作。所有强制转换获取相应对象的操作前提是在Init函数中具备对应赋值的操作。
该函数需要在驱动入口结构体中赋值给Release接口,当HDF框架调用Init函数初始化驱动失败时,可以调用Release释放驱动资源,该函数中需包含释放内存和删除控制器等操作。所有强制转换获取相应对象的操作前提是在Init函数中具备对应赋值的操作。
```
......
......@@ -76,7 +76,7 @@ PWM模块适配HDF框架的三个环节是配置属性文件,实例化驱动
HDF_INIT(g_hdfPwm);
```
2. 完成驱动入口注册之后,下一步请在device_info.hcs文件中添加deviceNode信息,并在 pwm_config.hcs 中配置器件属性。deviceNode信息与驱动入口注册相关,器件属性值与核心层PwmDev成员的默认值或限制范围有密切关系。 如有更多个器件信息,则需要在device_info文件增加deviceNode信息,以及在pwm_config文件中增加对应的器件属性**。**
2. 完成驱动入口注册之后,下一步请在device_info.hcs文件中添加deviceNode信息,并在 pwm_config.hcs 中配置器件属性。deviceNode信息与驱动入口注册相关,器件属性值与核心层PwmDev成员的默认值或限制范围有密切关系。如有更多个器件信息,则需要在device_info文件增加deviceNode信息,以及在pwm_config文件中增加对应的器件属性。
- device_info.hcs配置参考
......@@ -86,7 +86,7 @@ PWM模块适配HDF框架的三个环节是配置属性文件,实例化驱动
platform :: host {
hostName = "platform_host";
priority = 50;
device_pwm :: device {// 为每一个 pwm 控制器配置一个HDF设备节点,存在多个时【必须】添加,否则不用
device_pwm :: device {// 为每一个pwm控制器配置一个HDF设备节点
device0 :: deviceNode {
policy = 1; // 等于1,向内核态发布服务
priority = 80; // 驱动启动优先级
......@@ -116,16 +116,16 @@ PWM模块适配HDF框架的三个环节是配置属性文件,实例化驱动
root {
platform {
pwm_config {
template pwm_device { // 【必要】模板配置,继承该模板的节点如果使用模板中的默认值,则节点字段可以缺省
template pwm_device { // 【必要】模板配置,继承该模板的节点如果使用模板中的默认值,则节点字段可以缺省
serviceName = "";
match_attr = "";
num = 0; // 【必要】设备号
base = 0x12070000; // 【必要】地址映射需要
}
device_0x12070000 :: pwm_device {
device_0x12070000 :: pwm_device { // 存在多个设备时,请逐一添加相关HDF节点和设备节点信息。
match_attr = "hisilicon_hi35xx_pwm_0";// 【必要】需要和device_info.hcs中的deviceMatchAttr值一致
}
device_0x12070020 :: pwm_device { // 存在多个设备时【必须】添加,否则不用
device_0x12070020 :: pwm_device {
match_attr = "hisilicon_hi35xx_pwm_1";
num = 1;
base = 0x12070020; // 【必要】地址映射需要
......
......@@ -223,7 +223,7 @@ RTC模块适配HDF框架的三个环节是配置属性文件,实例化驱动
// 使HdfDeviceObject与RtcHost可以相互转化的前提
...
device->service = &host->service;// 使HdfDeviceObject与RtcHost可以相互转化的前提
// 方便后续通过调用RtcHostFromDevice 实现全局性质的host 使用
// 方便后续通过调用RtcHostFromDevice 实现全局性质的host
return HDF_SUCCESS;
}
```
......@@ -249,11 +249,11 @@ RTC模块适配HDF框架的三个环节是配置属性文件,实例化驱动
struct RtcHost *host = NULL;
struct RtcConfigInfo *rtcInfo = NULL;
...
host = RtcHostFromDevice(device);// 这里HdfDeviceObject到RtcHost的强制转化
host = RtcHostFromDevice(device);// 这里HdfDeviceObject到RtcHost的强制转化
rtcInfo = OsalMemCalloc(sizeof(*rtcInfo));
...
// HiRtcConfigData 会从设备配置树中读取属性填充rtcInfo 的supportAnaCtrl, supportLock, spiBaseAddr, regAddrLength, irq
// 为HiRtcSwInit和HiRtcSwInit提供参数,...函数内部处理失败后内存释放等操作
// 为HiRtcSwInit和HiRtcSwInit提供参数,当函数HiRtcSwInit和HiRtcSwInit内部执行失败后进行内存释放等操作
if (HiRtcConfigData(rtcInfo, device->property) != 0) {
...
}
......@@ -291,8 +291,8 @@ RTC模块适配HDF框架的三个环节是配置属性文件,实例化驱动
struct RtcHost *host = NULL;
struct RtcConfigInfo *rtcInfo = NULL;
...
host = RtcHostFromDevice(device); // 这里HdfDeviceObject到RtcHost的强制转化
rtcInfo = (struct RtcConfigInfo *)host->data;// 这里RtcHost到RtcConfigInfo的强制转化
host = RtcHostFromDevice(device); // 这里HdfDeviceObject到RtcHost的强制转化
rtcInfo = (struct RtcConfigInfo *)host->data;// 这里RtcHost到RtcConfigInfo的强制转化
if (rtcInfo != NULL) {
HiRtcSwExit(rtcInfo);
OsalMemFree(rtcInfo); // 释放RtcConfigInfo
......
......@@ -8,4 +8,3 @@
- [移植常见问题](faqs-porting.md)
- [启动恢复常见问题](faqs-startup.md)
- [系统应用常见问题](faqs-system-applications.md)
......@@ -9,25 +9,25 @@
### 轻量和小型系统
- [hb安装过程中出现乱码、段错误](../faqs/faqs-environment-building.md)
- [hb安装过程中出现乱码、段错误](../faqs/faqs-environment-setup.md)
- [hb安装过程中提示"cannot import 'sysconfig' from 'distutils'"](../faqs/faqs-environment-building.md)
- [hb安装过程中提示"cannot import 'sysconfig' from 'distutils'"](../faqs/faqs-environment-setup.md)
- [hb安装过程中提示"module 'platform' has no attribute 'linux_distribution'"](../faqs/faqs-environment-building.md)
- [hb安装过程中提示"module 'platform' has no attribute 'linux_distribution'"](../faqs/faqs-environment-setup.md)
- [hb安装过程中提示"Could not find a version that satisfies the requirement ohos-build"](../faqs/faqs-environment-building.md)
- [hb安装过程中提示"Could not find a version that satisfies the requirement ohos-build"](../faqs/faqs-environment-setup.md)
- [安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH”](../faqs/faqs-environment-building.md)
- [安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH”](../faqs/faqs-environment-setup.md)
- [安装python3过程中,提示“-bash: make: command not found”](../faqs/faqs-environment-building.md)
- [安装python3过程中,提示“-bash: make: command not found”](../faqs/faqs-environment-setup.md)
- [安装python3过程中,提示“zlib not available”](../faqs/faqs-environment-building.md)
- [安装python3过程中,提示“zlib not available”](../faqs/faqs-environment-setup.md)
- [编译构建过程中,提示“No module named 'Crypto'”](../faqs/faqs-environment-building.md)
- [编译构建过程中,提示“No module named 'Crypto'”](../faqs/faqs-environment-setup.md)
- [安装kconfiglib时,遇到lsb_release错误](../faqs/faqs-environment-building.md)
- [安装kconfiglib时,遇到lsb_release错误](../faqs/faqs-environment-setup.md)
- [Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt_pkg”](../faqs/faqs-environment-building.md)
- [Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt_pkg”](../faqs/faqs-environment-setup.md)
## 编译构建子系统
......@@ -116,16 +116,16 @@
## 移植
- [如何将用户的堆内存挂载进内核](../faqs/faqs-transplant.md)
- [如何将用户的堆内存挂载进内核](../faqs/faqs-porting.md)
## 启动恢复
- [系统启动过程中打印“parse failed!”错误后停止启动](../faqs/faqs-init.md)
- [系统启动过程中打印“parse failed!”错误后停止启动](../faqs/faqs-startup.md)
- [系统启动过程未结束就自动重启,如此反复持续](../faqs/faqs-init.md)
- [系统启动过程未结束就自动重启,如此反复持续](../faqs/faqs-startup.md)
- [参数正确的情况下调用SetParameter/GetParameter返回失败](../faqs/faqs-init.md)
- [参数正确的情况下调用SetParameter/GetParameter返回失败](../faqs/faqs-startup.md)
## 系统服务
......@@ -133,46 +133,46 @@
### 公共基础库
- [1.LiteOS-A内核(Hi3516、Hi3518平台)KV存储路径设置错误,导致KV存储运行失败](../faqs/faqs-system-using.md)
- [1.LiteOS-A内核(Hi3516、Hi3518平台)KV存储路径设置错误,导致KV存储运行失败](../faqs/faqs-system-applications.md)
### 视觉应用常见问题
- [是否存在一个全局变量,所有的页面都可以访问?](../faqs/faqs-system-using.md)
- [是否存在一个全局变量,所有的页面都可以访问?](../faqs/faqs-system-applications.md)
- [如何获取dom中的元素](../faqs/faqs-system-using.md)
- [如何获取dom中的元素](../faqs/faqs-system-applications.md)
- [如何在页面间传值?](../faqs/faqs-system-using.md)
- [如何在页面间传值?](../faqs/faqs-system-applications.md)
- [list如何滚动到某个item?](../faqs/faqs-system-using.md)
- [list如何滚动到某个item?](../faqs/faqs-system-applications.md)
- [text支持多行吗?](../faqs/faqs-system-using.md)
- [text支持多行吗?](../faqs/faqs-system-applications.md)
- [为什么控件不显示?](../faqs/faqs-system-using.md)
- [为什么控件不显示?](../faqs/faqs-system-applications.md)
- [如何实现页面滑动?](../faqs/faqs-system-using.md)
- [如何实现页面滑动?](../faqs/faqs-system-applications.md)
- [Left、Top为什么不生效?](../faqs/faqs-system-using.md)
- [Left、Top为什么不生效?](../faqs/faqs-system-applications.md)
- [动态绑定为什么不生效?](../faqs/faqs-system-using.md)
- [动态绑定为什么不生效?](../faqs/faqs-system-applications.md)
- [如何实现相对定位和绝对定位?](../faqs/faqs-system-using.md)
- [如何实现相对定位和绝对定位?](../faqs/faqs-system-applications.md)
- [如何控制控件的显示与隐藏?](../faqs/faqs-system-using.md)
- [如何控制控件的显示与隐藏?](../faqs/faqs-system-applications.md)
- [使用Margin时,有什么注意事项?](../faqs/faqs-system-using.md)
- [使用Margin时,有什么注意事项?](../faqs/faqs-system-applications.md)
- [使用事件订阅时,有什么注意事项?](../faqs/faqs-system-using.md)
- [使用事件订阅时,有什么注意事项?](../faqs/faqs-system-applications.md)
- [使用动态绑定时,有什么注意事项?](../faqs/faqs-system-using.md)
- [使用动态绑定时,有什么注意事项?](../faqs/faqs-system-applications.md)
- [swiper loop属性如何生效?](../faqs/faqs-system-using.md)
- [swiper loop属性如何生效?](../faqs/faqs-system-applications.md)
- [使用数组时,有什么注意事项?](../faqs/faqs-system-using.md)
- [使用数组时,有什么注意事项?](../faqs/faqs-system-applications.md)
### hdc
- [hdc_std连接不到设备](../faqs/faqs-system-using.md)
- [hdc_std连接不到设备](../faqs/faqs-system-applications.md)
- [hdc_std运行不了](../faqs/faqs-system-using.md)
- [hdc_std运行不了](../faqs/faqs-system-applications.md)
# 启动恢复常见问题
# startup常见问题
## 启动恢复常见问题
## 系统启动过程中打印“parse failed!”错误后停止启动
### 系统启动过程中打印“parse failed!”错误后停止启动
**现象描述**
......@@ -20,7 +21,7 @@
仔细检查init.cfg文件,确保其格式符合json格式要求。
## 系统启动过程未结束就自动重启,如此反复持续
### 系统启动过程未结束就自动重启,如此反复持续
**现象描述**
......@@ -43,7 +44,7 @@
2. 也可以将崩溃/报错退出的服务的“importance”属性改为0,然后重新烧写镜像,这样即使其退出,init也不会重启单板。
## 参数正确的情况下调用SetParameter/GetParameter返回失败
### 参数正确的情况下调用SetParameter/GetParameter返回失败
**现象描述**
......@@ -58,7 +59,7 @@
无需处理
## ueventd服务启动后报获取socket失败,尝试创建
### ueventd服务启动后报获取socket失败,尝试创建
**现象描述**
......@@ -80,8 +81,7 @@ ueventd服务启动后,首先出现打印 “Failed to get uevent socket, try
对于原因2,则需要查看所有cfg文件找到重复配置的ueventd服务,并将其删除,最终只保留一个有效的ueventd服务配置。
## ueventd服务轮询socket超时,并自动退出
### ueventd服务轮询socket超时,并自动退出
**现象描述**
......@@ -95,8 +95,7 @@ ueventd服务启动一段时间后,出现打印 “poll ueventd socket timeout
正常行为,无需解决。
## 配置了ondemand属性的服务无法被正确解析启动
### 配置了ondemand属性的服务无法被正确解析启动
**现象描述**
......@@ -111,7 +110,7 @@ ueventd服务启动一段时间后,出现打印 “poll ueventd socket timeout
确认该服务是否要做成按需启动的服务,如果不是,就不需要配置ondemand属性;如果是,则在配置了ondemand属性后,不可再配置critical属性,若是需要critical中的服务异常退出次数限制,请将critical属性数组中的第一个值配置为0再加次数限制,例如"critical" : [0, 15, 5],代表该服务在5秒钟内启动退出超过15次,将不再启动该服务,并且不会导致系统重启。
## 配置了ondemand属性的服务不受并行启动控制
### 配置了ondemand属性的服务不受并行启动控制
**现象描述**
......@@ -125,8 +124,7 @@ ueventd服务启动一段时间后,出现打印 “poll ueventd socket timeout
若要一个服务加入并行启动,不应为其配置ondemand属性。
## SA按需启动服务无法实现按需拉起
### SA按需启动服务无法实现按需拉起
**现象描述**
......@@ -139,3 +137,130 @@ ueventd服务启动一段时间后,出现打印 “poll ueventd socket timeout
**解决办法**
在按需启动的SA服务中使用samgr提供的动态加载接口LoadSystemAbility(int32_t systemAbilityId, const sptr& callback)。
### dac配置不合理
**现象描述**
dac 配置错误,会导致配置失效,报错如下:
```
4.619955] [pid=1 0][Init][ERROR][init_capability.c:119]service=multimodalinput not support caps = CAP_DC_OVERRIDE caps 41
[ 4.620014] [pid=1 0][Init][ERROR][init_service_manager.c:818]GetServiceSecon secon section not found, skip
[ 4.620216] [pid=1 0][Init][ERROR][init_service_manager.c:818]GetServiceSecon secon section not found, skip
[ 4.620608] [pid=1 0][Init][ERROR][init_capability.c:119]service=mmi_uinput_service not support caps = CAP_DC_OVERRIDE caps 41
```
**可能原因**
1. caps配置问题,防止配置最大属性。
2. 带CAP和非CAP开头的解析能力。
3. const问题。
**解决办法**
1. 支持带CAP和非CAP开头的解析能力。
2. 解决caps配置问题,防止配置最大属性。
3. 添加const属性文件,修复可以产品覆盖平台的。
### critical属性配置不生效
**现象描述**
配置critical 不生效。
**可能原因**
1. critical 配置格式是否有效。
2. 配置critical 的服务是否拉起。
3. 修改的配置文件是否生效。
**解决办法**
1. 修改配置文件格式可能存在问题。
2. 配置critical的服务可能不存在。
3. 不同设备对应的配置文件不同。3516设备修改init.cfg, RK3568设备修改init.without_two_stages.cfg。
### 不支持socket类进程按需启动
**现象描述**
不支持socket类进程按需启动。
**可能原因**
ueventd按需启动,DISABLE_INIT_TWO_STAGES宏的修改失效。
**解决办法**
在startUeventd中关闭socket,未能在在创建socket函数中增加了对socket有效性的检查, 故可能未做socket有效性检查导致的异常。
### 小型系统编译告警
**现象描述**
warning: implicit declaration of function 'usleep' is invalid in C99。
warning: implicit declaration of function 'setgroups' is invalid in C99。
**可能原因**
头文件可能包含错误, _GNU_SOURCE宏可能未打开。
**解决办法**
检查对应头文件是否包含正确, 如果正确, _GNU_SOURCE宏是否打开。
## Appspawn应用孵化常见问题
### 系统启动中,appspawn启动失败
**现象描述**
系统启动过程中,系统停止开机动画中, 进入appspawn失败。
**可能原因**
1. 开机动画未能正常退出。
2. 拉起系统应用失败, 导致appspawn启动失败。
**解决办法**
需要通过日志确认崩溃或报错退出的服务,并解决其崩溃/报错的问题,然后重新烧写镜像即可。
### 冷启动应用失败
**现象描述**
通过冷启动命令拉起应用失败。
```
aa start -d 12345 -a $name -b $package -C
```
**可能原因**
1. 冷启动未能生效。
2. 确认冷启动命令正确。
**解决办法**
1. 需要设置 param set appspawn.cold.boot true 确认冷启动时候生效。
2. 确认冷启动命令正确。
### 应用沙盒创建失败
**现象描述**
systemui启动失败,卡顿在OpenHarmony开机动画中,或者计算器应用无法点击, 字体不能正常显示等。hilog日志中报错:
- bind mount `<src-path>` to `<sandbox-path>` failed errno `<errorCode>`
- private mount to `<sandbox-path>` failed errno `<errorCode>`
- symlink failed, `<link-name>`, errno is `<errorCode>`
**可能原因**
1. 沙盒流程创建是否正确。
2. com.ohos.systemui 沙盒创建失败。
3. 沙盒应用依赖的文件配置失败。
**解决办法**
1. 查看hilog日志中,出现的相关hilog报错信息,针对报错修改对应的json文件。
2. 查看对应应用的pid情况,排查沙盒建立过程的代码逻辑,以及相应的json配置的正确性。
\ No newline at end of file
......@@ -53,14 +53,25 @@ OpenHarmony是由开放原子开源基金会(OpenAtom Foundation)孵化及
git config --global credential.helper store
```
4. 安装码云repo工具,可以执行如下命令。
4. 执行如下命令安装码云repo工具。
下述命令中的安装路径以"~/bin"为例,请用户自行创建所需目录。
```
curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中
chmod a+x /usr/local/bin/repo
mkdir ~/bin
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo
chmod a+x ~/bin/repo
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
```
5. 将repo添加到环境变量。
```
vim ~/.bashrc # 编辑环境变量
export PATH=~/bin:$PATH # 在环境变量的最后添加一行repo路径信息
source ~/.bashrc # 应用环境变量
```
### 操作步骤
......@@ -176,23 +187,22 @@ OpenHarmony是由开放原子开源基金会(OpenAtom Foundation)孵化及
| **LTS版本源码** | **版本信息** | **下载站点** | **SHA256校验码** |
| -------- | -------- | -------- | -------- |
| 全量代码(标准、轻量和小型系统) | 3.0 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.0/code-v3.0-LTS.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.0/code-v3.0-LTS.tar.gz.sha256) |
| 标准系统解决方案(二进制) | 3.0 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.0/standard.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.0/standard.tar.gz.sha256) |
| Hi3861解决方案(二进制) | 3.0 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_pegasus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_pegasus.tar.gz.sha256) |
| Hi3518解决方案(二进制) | 3.0 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_aries.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_aries.tar.gz.sha256) |
| Hi3516解决方案-LiteOS(二进制) | 3.0 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_taurus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_taurus.tar.gz.sha256) |
| Hi3516解决方案-Linux(二进制) | 3.0 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_taurus_linux.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.0/hispark_taurus_linux.tar.gz.sha256) |
| 全量代码(标准、轻量和小型系统) | 3.0 | [站点](https://repo.huaweicloud.com/openharmony/os/3.0/code-v3.0-LTS.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.0/code-v3.0-LTS.tar.gz.sha256) |
| 标准系统解决方案(二进制) | 3.0 | [站点](https://repo.huaweicloud.com/openharmony/os/3.0/standard.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.0/standard.tar.gz.sha256) |
| Hi3861解决方案(二进制) | 3.0 | [站点](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_pegasus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_pegasus.tar.gz.sha256) |
| Hi3518解决方案(二进制) | 3.0 | [站点](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_aries.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_aries.tar.gz.sha256) |
| Hi3516解决方案-LiteOS(二进制) | 3.0 | [站点](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus.tar.gz.sha256) |
| Hi3516解决方案-Linux(二进制) | 3.0 | [站点](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) |
| RELEASE-NOTES | 3.0 | [站点](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/zh-cn/release-notes/OpenHarmony-v3.0-LTS.md) | - |
| **最新发布版本源码** | **版本信息** | **下载站点** | **SHA256校验码** |
| 全量代码Release版本(标准、轻量和小型系统) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/code-v3.1-Release.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/code-v3.1-Release.tar.gz.sha256) |
| Hi3516标准系统解决方案(二进制) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/standard_hi3516.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/standard_hi3516.tar.gz.sha256) |
| RK3568标准系统解决方案(二进制) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/standard_rk3568.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/standard_rk3568.tar.gz.sha256) |
| Hi3861解决方案(二进制) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/hispark_pegasus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/hispark_pegasus.tar.gz.sha256) |
| Hi3516解决方案-LiteOS(二进制) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/hispark_taurus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/hispark_taurus.tar.gz.sha256) |
| Hi3516解决方案-Linux(二进制) | 3.1 Release | [站点](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/hispark_taurus_linux.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/harmonyos/os/3.1-Release/hispark_taurus_linux.tar.gz.sha256) |
| RELEASE-NOTES | 3.1 Release | [站点](https://gitee.com/openharmony/docs/blob/master/zh-cn/release-notes/OpenHarmony-v3.1-release.md) | - |
| 全量代码Beta版本(标准、轻量和小型系统) | 3.2 Beta1 | [站点](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/code-v3.2-Beta1.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/code-v3.2-Beta1.tar.gz.sha256) |
| RK3568标准系统解决方案(二进制) | 3.2 Beta1 | [站点](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/standard_rk3568.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/standard_rk3568.tar.gz.sha256) |
| Hi3861解决方案(二进制) | 3.2 Beta1 | [站点](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_pegasus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_pegasus.tar.gz.sha256) |
| Hi3516解决方案-LiteOS(二进制) | 3.2 Beta1 | [站点](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus.tar.gz.sha256) |
| Hi3516解决方案-Linux(二进制) | 3.2 Beta1 | [站点](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus_linux.tar.gz) | [SHA256校验码](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus_linux.tar.gz.sha256) |
| RELEASE-NOTES | 3.2 Beta1 | [站点](https://gitee.com/openharmony/docs/blob/master/zh-cn/release-notes/OpenHarmony-v3.2-beta1.md) | - |
| **编译工具链** | **版本信息** | **下载站点** | **SHA256校验码** |
| 编译工具链获取清单 | - | [站点](https://repo.huaweicloud.com/harmonyos/os/2.0/tool_chain/) | - |
| 编译工具链获取清单 | - | [站点](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/) | - |
## 获取方式4:从github镜像仓库获取
......
......@@ -128,6 +128,12 @@ source "drivers/staging/hilog/Kconfig"
source "drivers/staging/hievent/Kconfig"
```
在三方内核的drivers/staging/Makefile文件内增加如下代码:
```
obj-$(CONFIG_HILOG) += hilog/
obj-$(CONFIG_HIEVENT) += hievent/
```
在内核config项中打开对应的CONFIG控制宏:CONFIG_HILOG和CONFIG_HIEVENT。
具体日志使用说明请参见:[Hilog_lite组件介绍](https://gitee.com/openharmony/hiviewdfx_hilog_lite/blob/master/README_zh.md)
......
......@@ -61,7 +61,7 @@ OpenHarmony基于Hi3861平台提供了多种开放能力,提供的关键组件
| 设备安全绑定 | 提供在设备互联场景中,数据在设备之间的安全流转的能力。 |
| 基础加解密 | 提供密钥管理、加解密等能力。 |
| 系统服务管理 | 系统服务管理基于面向服务的架构,提供了OpenHarmony统一化的系统服务开发框架。 |
| 启动引导 | 提供系统服务的启动入口标识。在系统服务管理启动时,调用boostrap标识的入口函数,并启动系统服务。 |
| 启动引导 | 提供系统服务的启动入口标识。在系统服务管理启动时,调用bootstrap标识的入口函数,并启动系统服务。 |
| 系统属性 | 提供获取与设置系统属性的能力。 |
| 基础库 | 提供公共基础库能力。包括:文件操作、KV存储管理等。 |
| DFX | 提供DFX能力。包括:流水日志、时间打点等。 |
......
......@@ -11,6 +11,7 @@
2. 注册码云SSH公钥,请参考[码云帮助中心](https://gitee.com/help/articles/4191)
3. 安装git客户端和git-lfs。(上述工具已在搭建环境章节安装。如已安装,请忽略)
更新软件源:
```
......@@ -33,12 +34,23 @@
5. 执行如下命令安装码云repo工具。
下述命令中的安装路径以"~/bin"为例,请用户自行创建所需目录。
```
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中
chmod a+x /usr/local/bin/repo
mkdir ~/bin
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo
chmod a+x ~/bin/repo
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
```
6. 将repo添加到环境变量。
```
vim ~/.bashrc # 编辑环境变量
export PATH=~/bin:$PATH # 在环境变量的最后添加一行repo路径信息
source ~/.bashrc # 应用环境变量
```
## 获取方式
......@@ -65,6 +77,7 @@
```
- **OpenHarmony发布分支代码获取**
OpenHarmony各个版本发布分支的源码获取方式请参考[Release-Notes](../../release-notes/Readme.md)
......
......@@ -32,14 +32,25 @@
git config --global credential.helper store
```
5. 安装码云repo工具,可以执行如下命令。
5. 执行如下命令安装码云repo工具。
下述命令中的安装路径以"~/bin"为例,请用户自行创建所需目录。
```
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中
chmod a+x /usr/local/bin/repo
mkdir ~/bin
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo
chmod a+x ~/bin/repo
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
```
6. 将repo添加到环境变量。
```
vim ~/.bashrc # 编辑环境变量
export PATH=~/bin:$PATH # 在环境变量的最后添加一行repo路径信息
source ~/.bashrc # 应用环境变量
```
## 获取方式
......
......@@ -263,12 +263,23 @@
5. 执行如下命令安装码云repo工具。
下述命令中的安装路径以"~/bin"为例,请用户自行创建所需目录。
```
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中
chmod a+x /usr/local/bin/repo
mkdir ~/bin
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo
chmod a+x ~/bin/repo
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
```
6. 将repo添加到环境变量。
```
vim ~/.bashrc # 编辑环境变量
export PATH=~/bin:$PATH # 在环境变量的最后添加一行repo路径信息
source ~/.bashrc # 应用环境变量
```
### 获取方式
......
......@@ -61,7 +61,7 @@ OpenHarmony基于Hi3861平台提供了多种开放能力,提供的关键组件
| 设备安全绑定 | 提供在设备互联场景中,数据在设备之间的安全流转的能力。 |
| 基础加解密 | 提供密钥管理、加解密等能力。 |
| 系统服务管理 | 系统服务管理基于面向服务的架构,提供了OpenHarmony统一化的系统服务开发框架。 |
| 启动引导 | 提供系统服务的启动入口标识。在系统服务管理启动时,调用boostrap标识的入口函数,并启动系统服务。 |
| 启动引导 | 提供系统服务的启动入口标识。在系统服务管理启动时,调用bootstrap标识的入口函数,并启动系统服务。 |
| 系统属性 | 提供获取与设置系统属性的能力。 |
| 基础库 | 提供公共基础库能力。包括:文件操作、KV存储管理等。 |
| DFX | 提供DFX能力。包括:流水日志、时间打点等。 |
......
......@@ -265,12 +265,23 @@
5. 执行如下命令安装码云repo工具。
下述命令中的安装路径以"~/bin"为例,请用户自行创建所需目录。
```
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /usr/local/bin/repo #如果没有权限,可下载至其他目录,并将其配置到环境变量中
chmod a+x /usr/local/bin/repo
mkdir ~/bin
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo
chmod a+x ~/bin/repo
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
```
6. 将repo添加到环境变量。
```
vim ~/.bashrc # 编辑环境变量
export PATH=~/bin:$PATH # 在环境变量的最后添加一行repo路径信息
source ~/.bashrc # 应用环境变量
```
### 获取方式
......
......@@ -27,7 +27,7 @@
支持使用LiteOS-M内核的平台。
提供了各服务和功能的启动入口标识。在SAMGR启动时,会调用boostrap标识的入口函数,并启动系统服务。
提供了各服务和功能的启动入口标识。在SAMGR启动时,会调用bootstrap标识的入口函数,并启动系统服务。
- syspara系统参数组件
......
......@@ -6,7 +6,7 @@
**轻量系统基础能力增强**
轻量LiteOS系统和Linux系统IPC归一,构建和完善了进程间通信能力,包括分布式进程间通信,为分布式业务及APP提供本地和分布式的进程间通信能力
轻量LiteOS系统和Linux系统IPC归一,构建和完善了进程间通信能力。
**标准系统基础能力增强**
......@@ -51,8 +51,8 @@ ArkUI支持AbilityComponent组件将应用界面(Ability)作为控件嵌入
| -------- | -------- | -------- |
| OpenHarmony | 3.2&nbsp;Beta1 | NA |
| SDK | Ohos_sdk_full&nbsp;3.2.2.5 (API&nbsp;Version&nbsp;9 Beta1) | NA |
| HUAWEI&nbsp;DevEco&nbsp;Studio(可选) | 3.2&nbsp;Beta1&nbsp;for&nbsp;OpenHarmony | OpenHarmony应用开发推荐使用 |
| HUAWEI&nbsp;DevEco&nbsp;Device&nbsp;Tool(可选) | 3.2&nbsp;Beta1 | OpenHarmony智能设备集成开发环境推荐使用 |
| HUAWEI&nbsp;DevEco&nbsp;Studio(可选) | 3.0 Beta3 for&nbsp;OpenHarmony | OpenHarmony应用开发推荐使用 |
| HUAWEI&nbsp;DevEco&nbsp;Device&nbsp;Tool(可选) | 3.0 Release | OpenHarmony智能设备集成开发环境推荐使用 |
## 源码获取
......@@ -142,7 +142,7 @@ ArkUI支持AbilityComponent组件将应用界面(Ability)作为控件嵌入
| 子系统名称 | 标准系统 | 轻量、小型系统 |
| -------- | -------- | -------- |
| 公共 | 新增支持Arm架构64位版本编译构建。 | 轻量、小型系统IPC接口与标准系统归一化。 |
| 公共 | 新增支持Arm架构64位版本编译构建。 | 轻量、小型系统IPC接口归一。 |
| 资源调度 | 新增卡片使用记录信息统计能力。<br/>主要涉及如下需求:<br/>I531ST&nbsp;支持卡片卸载时,删除对应的卡片使用记录<br/>I531SU&nbsp;支持查询获取卡片使用记录<br/>I531SV&nbsp;支持记录卡片的使用计数以及使用时间 | NA |
| 多模输入 | 新增遥控器、鼠标、键盘输入设备热插拔监听能力。<br/>主要涉及如下需求:<br/>I530U7&nbsp;三方件json版本升级<br/>I530UH&nbsp;启动优化<br/>I530UU&nbsp;支持裁剪鼠标光标显示特<br/>I530UL&nbsp;支持不可触摸窗口<br/>I530W5&nbsp;支持通过JS&nbsp;API监听遥控器输入设备的热插拔<br/>I530W9&nbsp;支持通过JS&nbsp;API监听鼠标输入设备的热插拔<br/>I530WB&nbsp;支持通过JS&nbsp;API查看触摸板输入设备扩展信息<br/>I530WF&nbsp;支持通过JS&nbsp;API监听键盘输入设备的热插拔<br/>I530UW&nbsp;支持裁剪配置组合按键特性 | NA |
| 系统服务管理 | 新增群组校验机制。<br/>主要涉及如下需求:<br/>I59XYB&nbsp;添加群组校验机制<br/>I53NZQ&nbsp;处理远端应用安装情况和版本号<br/>I568AO&nbsp;DMS上报分布式组件关联关系<br/>I58ZSB&nbsp;采集OS类型信息 | NA |
......
......@@ -8,7 +8,7 @@ OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本的JS API变更
- [电源服务](js-apidiff-battery.md)
- [包管理](js-apidiff-bundle.md)
- [基础通信](js-apidiff-communicate.md)
- [语言编译器运行时](js-apidiff-complier-and-runtime.md)
- [语言编译器运行时](js-apidiff-compiler-and-runtime.md)
- [DFX](js-apidiff-dfx.md)
- [分布式数据管理](js-apidiff-distributed-data.md)
- [分布式硬件](js-apidiff-distributed-hardware.md)
......
......@@ -59,7 +59,7 @@
- [电源服务](release-notes/api-change/v3.1-Release/js-apidiff-battery.md)
- [包管理](release-notes/api-change/v3.1-Release/js-apidiff-bundle.md)
- [基础通信](release-notes/api-change/v3.1-Release/js-apidiff-communicate.md)
- [语言编译器运行时](release-notes/api-change/v3.1-Release/js-apidiff-complier-and-runtime.md)
- [语言编译器运行时](release-notes/api-change/v3.1-Release/js-apidiff-compiler-and-runtime.md)
- [DFX](release-notes/api-change/v3.1-Release/js-apidiff-dfx.md)
- [分布式数据管理](release-notes/api-change/v3.1-Release/js-apidiff-distributed-data.md)
- [分布式硬件](release-notes/api-change/v3.1-Release/js-apidiff-distributed-hardware.md)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册